每次都会显示XAMPP访问禁止错误

问题描述 投票:0回答:1

操作系统: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
php mysql apache xampp
1个回答
0
投票

好的家伙所以我发现了问题......我是这些事情的真正新手。因此将文件保存为“index.php”而不是“index.html”解决了这个问题。

我们可以关闭这个话题。

© www.soinside.com 2019 - 2024. All rights reserved.