【问题标题】:Default 404 error page instead of custom?默认 404 错误页面而不是自定义?
【发布时间】:2014-10-30 18:18:22
【问题描述】:

为什么这个页面返回默认的404页面:http://example.com/this%2Fthis
但是这个返回自定义的:http://example.com/this/this
这个也返回自定义的:http://example.com/?i=this%2Fthis

这是我的 htaccess 文件:

ErrorDocument 404 http://example.com/?id=error

在我的 htaccess 中,我明确指定了所有错误应重定向到的页面。在第一种情况下,我得到的是默认错误页面,而不是我的自定义页面。

问题是,我必须在我的 htaccess 文件中添加什么才能使 url 正常工作并重定向到自定义错误页面?

【问题讨论】:

  • @anubhava:是的,上面一行是我完整的.htaccess

标签: php apache redirect http-status-code-404


【解决方案1】:

此行为是出于安全原因。

出于安全原因,包含 %2f%5c 字符的 URL 只会从 Apache 返回默认的 404

Related Apache docs

Also see: 5 Solutions to Url Encoded Slashes (%2F) Problem in Apache

【讨论】:

  • 那是因为%2F 在查询字符串中而不是在主 URI 中
猜你喜欢
  • 1970-01-01
  • 2020-11-16
  • 1970-01-01
  • 2021-10-26
  • 2019-04-03
  • 1970-01-01
  • 2016-04-25
  • 2013-09-16
  • 1970-01-01
相关资源
最近更新 更多