I have a site that I have updated with new content and new pages. Around 20 pages are now gone but still show up in google. Can somebody tell me how to redirect all these lost pages to my main index page please...
Try with this: ErrorDocument 404 /index.html Code (markup): Use your own homepage: index.php, index.htm, ...
That doesn't just send your old pages to the index, it sends everything that should generate a 404 error to the index page - and there's a good reason for sending back a 404 error instead of another page. It also doesn't redirect to the index.html, it shows the index.html page as if it were the requested page, so there's a bit of duplicate content there.. Assuming you don't have a robots.txt or favicon.ico, whenever these get requested, instead of a usual 404 response you'll be sending back a 200 and the search engine will try and interpret your index page as a valid robots.txt file (which will obviously cause it problems) and browsers will try and use your index page as the icon, which obviously won't work either. Above all, it's a massive waste of bandwidth. Even if you do have these files, it's generally not a good idea to use your index page as the 404 document unless you have a reason. If it's only ~20 pages, you'd be better off manually 301 redirecting each to either a corresponding new page or the index page. Redirect /path/to/old.page http://url.to/new.page Code (markup):
Thanks Rodney that makes sense. I will give over an hour or 2 later today and redirect the lost pages the way you have shown me.
rodney, even though it shows the index page as the 404 page, Google and other bots can still recognise that page resulted in a 404 so no duplicate content issues should arise. That being said, 404 pages are useful. So instead of using your index page for 404 errors, just keep the normal 404 page and Google will eventually pull the sites out of the index next time it tries to crawl the site. And for now, how about have a custom 404 page and have a script that checks the request to see if it was one of the deleted pages and just inform the user that it has been deleted with a link to the index/related pages.
Whenever I use custom error documents on my server, I have to manually send the 404 status code with a php header, otherwise it sends 200. I assumed that was the default behaviour but the manual makes no mention of it so I guess I need to look into that and see what's wrong. So yeh, ignore duplicate content, my mistake.