我正在使用 PHP。我有一个如下所示的 .htaccess 文件,它重定向到主页而不是 404 错误页面:/这里可能是什么问题?感谢帮助!非常感谢!
ErrorDocument 404 /new/err404.html
RewriteEngine On
RewriteBase /new/
RewriteRule ^login.html$ index.php?s=login&a=loginDo [QSA,L]
RewriteRule ^logout.html$ index.php?s=login&a=logoutDo [QSA,L]
RewriteRule ^([^/]*).html$ index.php?s=$1 [QSA,L]
RewriteRule ^members/([^/]*)$ index.php?s=profile&username=$1 [QSA,L]
RewriteRule ^([^/]*)/$ index.php?s=listing&search[cityString]=$1 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/$ index.php?s=listing&search[neighborhoodString]=$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*).html$ index.php?s=details&seo_friendly=$3 [QSA,L]
最佳答案
没有路径前缀 /new/
的 URL 路径或错误文档 /new/err404.html
只是 err404.html
。这将与您的第三条规则相匹配。
您可以扩展该规则并排除此类错误文档:
RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^([^/]*)\.html$ index.php?s=$1 [QSA,L]
关于php - 重定向到主页而不是 404 错误页面!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1565628/