Forum Moderators: Robert Charlton & goodroi
would it be wise to 301 redirect all these URLs to the correct ones?If and only if
I redirect all my 404 pages to search pages.
HELP! MY SITE HAS 939 CRAWL ERRORS!1And five more observations worth reading, with links to longer posts worth checking out too.
I see this kind of question several times a week; you're not alone - many websites have crawl errors.
1) 404 errors on invalid URLs do not harm your site's indexing or ranking in any way. It doesn't matter if there are 100 or 10 million, they won't harm your site's ranking. [googlewebmastercentral.blogspot.ch...]
2) In some cases, crawl errors may come from a legitimate structural issue within your website or CMS. How you tell? Double-check the origin of the crawl error. If there's a broken link on your site, in your page's static HTML, then that's always worth fixing. (thanks +Martino Mosna)
if(is_404()){ //redirect 404 to search
header("HTTP/1.1 301 Permanent Redirect");
header( 'Location: https://www.mydomain.com?s='.urlencode(preg_replace('/[^A-Za-z0-9\s]/',' ',$_SERVER['REQUEST_URI'])));
die;
}
Do you see any issues?
I hope your URLs don't actually contain spaces.
if a request for https://www.example.com/arbitrary_string/ would normally cause a 404, your script will redirect this request to https://www.example.com?s=arbitrary_string/
https://www.example.com?s=arbitrary_string/ returns 200 ok search page (different from https://www.example.com/)