重定向到首页,而不是404错误页面! [英] redirecting to homepage rather than 404 error page!

查看:340
本文介绍了重定向到首页,而不是404错误页面!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP。我有一个.htaccess文件,如下所示,它重定向到首页而不是404错误页面:/这可能是什么问题?感谢帮助!

I'm working with PHP. I have an .htaccess file like below, and it redirects to homepage rather than 404 error page :/ what can be the problem here? Appreciate helps! thanks a lot!

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]


推荐答案

URL路径或错误文档 /new/err404.html / new / 的code>只是 err404.html 。这将与您的第三条规则匹配。

The URL path or your error document /new/err404.html without the path prefix /new/ is just err404.html. And that will be matched by your third rule.

您可以扩展该规则并排除此类错误文档:

You could extend that rule and exclude such the error documents:

RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^([^/]*)\.html$ index.php?s=$1 [QSA,L]

这篇关于重定向到首页,而不是404错误页面!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆