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

时间:2019-04-24 23:45:08

标签: php mysql apache xampp

操作系统:Windows 10-64bit 示例代码:

<!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

1 个答案:

答案 0 :(得分:0)

好的,所以我发现了问题...在这些问题上我是一个真正的新手。因此,将文件另存为“ index.php”而不是“ index.html”即可解决此问题。

我们可以关闭主题。

相关问题