我在子文件夹中有一个网站,我有一个.htaccess文件,工作得很好,但如果规则没有找到任何东西,它会引发500内部服务器错误而不是404,但是我想我会解决它添加500错误文档, 但500错误页面(除经典500消息外)说:
“此外,遇到500内部服务器错误错误 试图使用ErrorDocument来处理请求。“
所以我有两个问题:
到目前为止,这是我的 .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]
答案 0 :(得分:1)
请尝试以下规则:
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]