【问题标题】:Why adding in the url "/something/watever" after a "page.php" doesn't trigger a 404?为什么在“page.php”之后添加 url “/something/waterver”不会触发 404?
【发布时间】:2019-08-08 08:39:22
【问题描述】:

我有一个网址为site.com/index.php 的网页。奇怪的是,当我将/something/whatever(或其他任何内容)添加到 URL 时,使其成为site.com/index.php/something/whateverindex.php 页面仍在加载。

我不明白为什么服务器不只是返回 404 Not Found 错误

我尝试过其他网站,例如 php.net。你可以试试https://www.php.net/manual/en/intro-whatcando.php/

然后在/ 之后添加一些内容,如下所示:https://www.php.net/manual/en/intro-whatcando.php/test/like/test/fuhzefuizh

我仍然不明白为什么它显示 page.php 而不是 404 错误(因为很明显,文件夹或 URI“fuhzefuizh”不存在)。

【问题讨论】:

  • mod_rewrite 可能有问题。这通常用于将所有 URL 重定向到单个 PHP 文件,以便您可以拥有动态路由等。

标签: php apache url


【解决方案1】:

我发现这是正常行为,具体取决于服务器配置。这是AcceptPathInfo 规则,我们可以用AcceptPathInfo off 将其关闭。

【讨论】:

    猜你喜欢
    • 2018-06-07
    • 2019-12-29
    • 2019-04-13
    • 1970-01-01
    • 2016-07-27
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    相关资源
    最近更新 更多