【发布时间】:2016-07-03 16:05:03
【问题描述】:
我编辑了我的 htaccess 文件以将 mysite.com/page 重写为 mysite.com/page.php 并在用户请求 mysite.com/page.php 而不是 mysite.com/page 时显示 404 错误页面
我还添加了我自己的自定义 404 错误页面
但是当我请求mysite.com/page.php 时,显示的错误页面是 Apache 默认的 404 错误页面(而不是我的自定义错误页面),并带有额外的错误信息:
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
我的错误日志:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
这是我的 htaccess 文件:
RewriteEngine On
RewriteBase /
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
ErrorDocument 404 /error/404
我已尝试将上面最后一行的 404 更改为 404.php,但自定义错误页面仍然没有显示..
但是,当我请求mysite.com/page/ 时,自定义错误页面确实出现了(注意斜线)。
【问题讨论】:
标签: php apache .htaccess mod-rewrite