簡體   English   中英

每次都會顯示XAMPP訪問禁止錯誤

[英]XAMPP Access Forbidden Error Shows Up Everytime

操作系統:Windows 10 - 64位示例代碼:

<!DOCTYPE html>
<html>
<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Name: <input type="text" name="fname">
  <input type="submit">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // collect value of input field
    $name = $_POST['fname'];
    if (empty($name)) {
        echo "Name is empty";
    } else {
        echo $name;
    }
}
?>

</body>
</html>

XAMPP服務器訪問錯誤令我望了好幾天。

我一直在努力這3天沒有運氣。 我已嘗試過本主題中提到的所有內容:

Xampp Access Forbidden php

在完成本主題中提到的所有更改之后,我停止並重新啟動“Apache”和“MySQL”。 然而,我仍然在下面發出這個惱人的警告。

Access forbidden!

You don't have permission to access the requested object.It is either read-protected or not readable by the server. 

If you think this is a server error, please contact the webmaster. 

Error 403

localhost
Apache/2.4.39 (Win64) OpenSSL/1.1.1b PHP/7.3.4 

在2019年解決這個問題的解決方案是什么?

謝謝。

我在error.log中收到此錯誤

[Wed Apr 24 20:41:41.883821 2019] [core:error] [pid 9380:tid 1904] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:50047] AH00127: Cannot map POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1 to file, referer: http://localhost/
[Wed Apr 24 20:41:45.143913 2019] [core:error] [pid 9380:tid 1904] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:50047] AH00127: Cannot map POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1 to file, referer: http://localhost/
[Wed Apr 24 20:42:49.563556 2019] [core:error] [pid 9380:tid 1904] (20024)The given path is misformatted or contained invalid characters: [client 127.0.0.1:50051] AH00127: Cannot map POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1 to file, referer: http://localhost/

和access.log

127.0.0.1 - - [24/Apr/2019:20:41:16 -0400] "GET /test/ HTTP/1.1" 404 1053
127.0.0.1 - - [24/Apr/2019:20:41:16 -0400] "GET /favicon.ico HTTP/1.1" 404 1053
127.0.0.1 - - [24/Apr/2019:20:41:28 -0400] "GET / HTTP/1.1" 200 421
127.0.0.1 - - [24/Apr/2019:20:41:41 -0400] "POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1" 403 1041
127.0.0.1 - - [24/Apr/2019:20:41:45 -0400] "POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1" 403 1041
127.0.0.1 - - [24/Apr/2019:20:42:49 -0400] "POST /%3C?php%20echo%20$_SERVER[%27PHP_SELF%27];?%3E HTTP/1.1" 403 1041

好的家伙所以我發現了問題......我是這些事情的真正新手。 因此將文件保存為“index.php”而不是“index.html”解決了這個問題。

我們可以關閉這個話題。

暫無
暫無

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

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