dou70260 2019-04-24 23:45
浏览 688

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

Operating System: Windows 10 - 64bit Sample Code:

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

I have been working on this for 3 days without any luck. I have tried everything mentioned in this topic:

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. 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?

Thanks.

I get this error in the 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

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条回答 默认 最新

  • douxiongzhen2126 2019-04-25 02:03
    关注

    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.

    We can close the topic.

    评论

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?