douhui9380 2018-02-09 07:24
浏览 56
已采纳

使用自定义错误页面.htaccess

I want to remove .php file extentions and add custom error page through .htaccess file.

Following is the complete code of my .htaccess file:

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 

The first part to remove extension works but second part does not work. It does not use the error500.php file. I have tried adding both with and without .php extention.

Here's the error that I get in the apache error.log

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

What I'm doing wrong?

  • 写回答

1条回答 默认 最新

  • douou0977 2018-02-09 08:15
    关注

    1) Could you try add RewriteBase

    2) Add the extension for 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 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度