redirecting to homepage rather than 404 error page!

微笑、不失礼 提交于 2019-12-04 13:49:31

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]

I think a more important question, is why you are redirecting 404's to your home page?

The user needs to know that the page is dead/bad, and so does Google. And you need to investigate where the 404's are coming from.

Redirecting your 404's to your home page will tell Google that your links are A-ok, and you may hurt your rankings depending on how many links are being redirected, as Google may see it as duplicate content.

Say you put a rule that affects 5,000 pages - then google comes and sees 5,000 URL's with the same exact content - the home page, how does it know those were supposed to be 404's to begin with?

Fix your 404's. And if you had legitimate content that needs redirecting, well, redirect them to their new page, or the closest semantic page available.

Why are you trying to use rewrite rules for your 404 error? Why not just use:

 ErrorDocument 404 /new/err404.html

like you have on the first line? Are you wanting the 404 to stay relative to the directory that the user is trying to go to?

utsav

try this lines in your .htaccess by changing domain and page name

ErrorDocument 404 http://www.yoursite.com/pagename.html

Just through your home page code into the redirect page. Change the code in the redirect page with your home page code. So you will have an /index.html and a /404.html with the same code - your home page. He He

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!