当试图使用ErrorDocument来处理请求500内部服务器错误 [英] 500 Internal Server Error when trying to use ErrorDocument to handle request
本文介绍了当试图使用ErrorDocument来处理请求500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个.htaccess文件:
选项-Indexes
RewriteEngine叙述上
ErrorDocument的404 /404.php
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^([^ /] *)/(。*)$ ./$1.php
的RewriteCond%{THE_REQUEST} \ .PHP
重写规则^ $(*) - [L,R = 404]
然而,当我去本地主机/使用example.php
,它返回一个500内部服务器错误。
任何帮助吗?谢谢你。
编辑:
出现的完整的错误信息是:
未找到
所请求的URL /example.php在此服务器上找到。
此外,试图使用ErrorDocument来处理请求500内部服务器错误时遇到错误。
解决方案
你最有可能获得500由于循环错误。
排除 404.php
从最后一条规则为:
的ErrorDocument 404 /404.php
选项-Indexes -MultiViews
RewriteEngine叙述上
的RewriteCond%{THE_REQUEST} \ .PHP [NC]
重写规则^(?!404 \ .PHP)$ - [L,NC,R = 404]
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^([^ /] +)/?(。*)$ ./$1.php [L]
I have this .htaccess file:
Options -Indexes
RewriteEngine on
ErrorDocument 404 /404.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]*)/?(.*)$ ./$1.php
RewriteCond %{THE_REQUEST} \.php
RewriteRule ^(.*)$ - [L,R=404]
However, when I go to localhost/example.php
, it returns a 500 Internal Server Error.
Any help please? Thanks.
EDIT:
The full error message that comes up is:
Not Found
The requested URL /example.php was not found on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
解决方案
You're most likely getting 500 due to looping error.
Exclude 404.php
from last rule as:
ErrorDocument 404 /404.php
Options -Indexes -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(?!404\.php)$ - [L,NC,R=404]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?(.*)$ ./$1.php [L]
这篇关于当试图使用ErrorDocument来处理请求500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文