簡體   English   中英

非理性禁止403錯誤消息

[英]Irrational Forbidden 403 Error Message

我有一個博客,上面有一個add-post.php頁面,其中包含一個帶有操作的簡單表格:

<form id="form" action="add-post-php.php" method="POST" enctype="multipart/form-data">

然后,我將文件add-post-php.phpadd-form.php放在同一文件夾中。 因此,我在表單中輸入博客的詳細信息,然后按提交並獲得:

禁止的

您無權訪問此服務器上的/add-post-php.php。

此外,嘗試使用ErrorDocument處理請求時遇到404 Not Found錯誤。

我已經在本地主機上對其進行了測試,並且可以正常工作,該文件的權限設置為0644,但是我也嘗試在0755對其進行嘗試,沒有任何改進。 我的.htaccess文件沒有問題,目錄中沒有其他.htaccess文件。

我完整的add-post-php.php腳本是:

<?php
include("php/settings.php"); // Contains DB Connections
?>
<?php
$id= time();
$month = date("m");
$year = date("Y");
$path = "images/posts/$year/$month/";

$section = $_POST["section"];
$category = $_POST["category"];
$credit = $_POST["credit"];
$title = ucwords($_POST["title"]);
$text = $_POST["text"];
$exclusive = $_POST["exclusive"];

$added = date("Y-m-d H:i:s");

$photo = $_FILES["photo"]["name"];
$ext = substr(strrchr($photo, '.'), 1);
?>
<?php
$insert_sql = "INSERT INTO posts (id, section, category, credit, title, article, exclusive, added) VALUES('$id', '$section', '$category', '$credit', '$title', '$text', '$exclusive', '$added')";
$insert_res = mysqli_query($con, $insert_sql);
if(mysqli_affected_rows($con)>0){
move_uploaded_file($_FILES["photo"]["tmp_name"],"$path" . $id . "." . $ext);
}
else{
echo "0";
exit();
};
?>
<?php
header("Location: post.php?id=$id");
exit();
?>

有誰知道文件清楚存在且權限正確的原因,為什么會出現“禁止錯誤”?

這是我的.htaccess:

Options -MultiViews

DirectoryIndex posts.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d    

RewriteRule ^posts/([0-9]+)/?$              posts.php?currentpage=$1 [NC,L,QSA]

RewriteRule ^section/([\w-]+)/?$            section.php?section=$1 [NC,L,QSA]
RewriteRule ^section/([\w-]+)/([0-9]+)/?$   section.php?section=$1&currentpage=$2 [NC,L,QSA]

RewriteRule ^posts/([\w-]+)/?$              posts.php?category=$1 [NC,L,QSA]
RewriteRule ^posts/([\w-]+)/([0-9]+)/?$     posts.php?category=$1&currentpage=$2 [NC,L,QSA]

RewriteRule ^post/([0-9]+)/([\w-]+)/?$      post.php?id=$1&title=$2 [NC,L,QSA]

RewriteRule ^sites/([0-9]+)/?$              sites.php?currentpage=$1 [NC,L,QSA]

RewriteRule ^posts posts.php
RewriteRule ^section section.php
RewriteRule ^sites sites.php

RewriteRule ^about about.php
RewriteRule ^advertise advertise.php
RewriteRule ^subscribe subscribe.php

資料夾結構:

在此處輸入圖片說明

我剛剛再次檢查了php錯誤日志,然后看到以下消息:

[2015年10月22日星期四13:04:14.575567] [:錯誤] [pid 1041578] [客戶端74.125.76.51:56087]文件不存在:/ home / fulldist / public_html / ***。com / feed.php,

[2015年10月22日星期四09:53:14.646744] [:錯誤] [pid 944286] [客戶端31.13.113.90:59997]文件不存在:/ home / fulldist / public_html / ***。com / blog.php。

的確feed.php和blog.php不存在,但是為什么要嘗試查找它們呢?

這沒錯嗎

header("Location: post.php?id=$id");

您是否不需要此標題

header("Location: posts/$id");

根據這個規則

RewriteRule ^posts/([0-9]+)/?$              posts.php?currentpage=$1 [NC,L,QSA]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM