1987WEB视界-分享互联网热点话题和事件

您现在的位置是:首页 > WEB开发 > 正文

WEB开发

重定向到首页,而不是404错误页面!

1987web2022-09-28WEB开发258
本文介绍了重定向到首页,而不是404错误页面!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!问题描述我正在使用

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

问题描述

我正在使用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]

推荐答案

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

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

RewriteCond $1 !^err[45][0-9][0-9]$

RewriteRule ^([^/]*)\.html$ index.php?s=$1 [QSA,L]

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