简体   繁体   English

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

[英]XAMPP Access Forbidden Error Shows Up Everytime

Operating System: Windows 10 - 64bit Sample Code: 操作系统: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 server access error is daunting me for days. XAMPP服务器访问错误令我望了好几天。

I have been working on this for 3 days without any luck. 我一直在努力这3天没有运气。 I have tried everything mentioned in this topic: 我已尝试过本主题中提到的所有内容:

Xampp Access Forbidden php Xampp Access Forbidden php

I stop and restart "Apache" and "MySQL" after doing all the changes one by one that are mentioned in this topic. 在完成本主题中提到的所有更改之后,我停止并重新启动“Apache”和“MySQL”。 Yet I still get this annoying warning down below. 然而,我仍然在下面发出这个恼人的警告。

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 

What is the solution to get around this in 2019? 在2019年解决这个问题的解决方案是什么?

Thanks. 谢谢。

I get this error in the error.log 我在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/

And access.log 和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

OK guys so I found the problem... I am a real newbie on these matters. 好的家伙所以我发现了问题......我是这些事情的真正新手。 So saving the file as "index.php" as opposed to "index.html" resolved the issue. 因此将文件保存为“index.php”而不是“index.html”解决了这个问题。

We can close the topic. 我们可以关闭这个话题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM