我知道这可能是重复的,但我有更好的细节。我将.htaccess文件设置为显示最常见错误的自定义错误页:
# remove .php
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
#Add custom error pages
ErrorDocument 404 /errors/404
ErrorDocument 403 /errors/403
ErrorDocument 500 /errors/500当我故意触发一个错误500时,它只会给我默认的Apache页面,并说:Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.,我可以通过输入localhost/errors/500来访问错误页面,这样就不会有权限问题了。我搜索了很多论坛,但没有找到解决方案。
编辑:错误500是由重写引擎的格式错误请求触发的。如果键入example.com/index/,它会尝试转到/index/.php,这会导致错误500。
发布于 2019-01-24 19:04:29
500内部服务器错误是一个非常普遍的错误。它表示服务器遇到严重错误,根本无法正常处理请求。
这500个错误中的许多都无法在.htaccess中定义为“延迟”的自定义错误文档中捕捉到。
如果在服务器配置中定义了ErrorDocument,则可能性更大。但即便如此,这也不足以弥补一些错误。
不过,话虽如此.
...and还说:
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.我可以通过键入localhost/Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request./500来访问错误页面,所以它没有权限。 编辑:错误500是由重写引擎发出的格式错误请求触发的。如果键入example.com/index/,它会尝试转到/index/.php,这会导致错误500。
它确实试图提供自定义( 500 )错误文档,但这也遇到了500错误。
具体来说,请求/index/会导致重写循环,即。从/index/.php到/index/.php.php到/index/.php.php.php等。当服务器达到内部重定向的极限(默认为10)时,它是否触发了500个错误。
是的,我在重写循环中也看到了这一点。尽管错误似乎不影响ErrorDocument的服务,但消息似乎表明了这一点。直接请求错误文档是可以的。
我想知道(纯粹是假设的)..。由于在此请求中已达到“内部重定向”限制(因为有重写循环),ErrorDocument (也由内部重定向提供)无法服务,因为此限制已经达到!?因此,这将触发一个500错误,出于同样的原因!严格地说,ErrorDocument是通过内部子请求(而不是内部重定向)服务的,尽管 directive似乎将“内部重定向”和“子请求”组合在一起。
除了在代码中触发500错误(如下所示),我想不出另一种触发500错误的方法(这是可以的)。代码中的任何(致命)解析错误都会在每个请求中触发500个错误。
RewriteRule ^foo$ - [R=500]以上应该为您的自定义500 ErrorDocument正常,ErrorDocument本身是好的。
https://stackoverflow.com/questions/54353420
复制相似问题