简体   繁体   English

500而不是404,500本身会抛出500

[英]500 instead of 404 and 500 throws 500 itself

I have a site in a subfolder in which I have a .htaccess file which works quite fine, but if the rules dont find anything, it raises a 500 internal server error istead of 404, however I thought I would solve it by adding a 500 Error document, but the 500 Error page (aside from classic 500 message) says: 我在子文件夹中有一个站点,在其中我有一个.htaccess文件,该文件可以正常运行,但是如果规则找不到任何内容,则会引发500内部服务器错误,而不是404,但是我想我可以通过添加500来解决该问题。错误文档,但“ 500错误”页面(除经典500消息外)显示:

"Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request." “此外,尝试使用ErrorDocument来处理请求时,遇到了500 Internal Server Error错误。”

So I have a two questions: 所以我有两个问题:

  1. Why is 500 raised instead of 404? 为什么加薪500而不是404?
  2. What is causing the "additional" error while handling 500 Error document? 是什么原因导致在处理500错误文档时出现“其他”错误?

This is my .htaccess so far: 到目前为止,这是我的.htaccess

DirectorySlash On

RewriteEngine On
RewriteBase /mysubdir/

ErrorDocument 404 /mysubdir/404.php
ErrorDocument 500 /mysubdir/500.php

RewriteRule ^folderexcludedone(/|$) - [NC,L]
RewriteRule ^folderexcludedtwo(/|$) - [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)$ $1/ [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ $1.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]*)/?$ $1.php?$1=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/([^/]*)/?$ $1.php?$2=$3 [L,QSA]

Try these rules: 尝试以下规则:

DirectorySlash On

RewriteEngine On
RewriteBase /mysubdir/

ErrorDocument 404 /mysubdir/404.php

RewriteRule ^(folderexcludedone|folderexcludedtwo)(/|$) - [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)$ $1/ [L,R]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/?$ $1.php [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/?$ $1.php?$1=$2 [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?$2=$3 [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM