【问题标题】:Using custom error page with .htaccess使用带有 .htaccess 的自定义错误页面
【发布时间】:2018-02-09 07:24:25
【问题描述】:

我想删除.php 文件扩展名并通过.htaccess 文件添加自定义错误页面。

以下是我的.htaccess文件的完整代码:

RewriteEngine On
#Remove .php file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*[^/])/?$ $1.php [L]

#Use error500.php file located in the root dir
ErrorDocument 500 /error500 

删除扩展的第一部分有效,但第二部分无效。它不使用error500.php 文件。我已经尝试添加和不添加 .php 扩展名。

这是我在 apache error.log 中遇到的错误

请求超出了 10 个内部的限制 由于可能的配置错误而重定向。利用 'LimitInternalRecursion' 必要时增加限制。利用 'LogLevel debug' 获取回溯。

我做错了什么?

【问题讨论】:

    标签: php apache .htaccess url-rewriting


    【解决方案1】:

    1) 可以试试添加 RewriteBase

    2) 添加error500的扩展名

    RewriteEngine on 
    RewriteBase /{FOLDER PATH HERE}
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php [NC,L]
    
    #Use error500.php file located in the root dir
    ErrorDocument 500 {YOUR DIRECTORY HERE}/error500.php 
    

    【讨论】:

      猜你喜欢
      • 2018-04-18
      • 1970-01-01
      • 2015-09-10
      • 2011-11-08
      • 2016-11-09
      • 2014-01-19
      • 1970-01-01
      • 2021-10-15
      相关资源
      最近更新 更多