404 page redirection

Permalink 1 user found helpful
Hello
Is there any simple way to redirect my visitors directly to the main page instead of 'page not found' page, when the url page doesn't exists ?
Thanks.

 
WebcentricLtd replied on at Permalink Best Answer Reply
hi,
rather than redirect them to your homepage you should really redirect them to a custom 404 page.

This can look exactly like your homepage if you like but if a page is missing then generally you should return a 404 so that it drops out of search engine indexes etc.

I have a blog post on this - rather than drop it here have PM'd you the link:
Philnext replied on at Permalink Reply
Thanks for this answer but I would prefere redirection to my home page because my site is changing and I want to maintain only one page.
olliephillips replied on at Permalink Reply
olliephillips
If you're moving/changing stuff then a 302 or 301 redirect is what you need. 404 says page not found, but what you want to do is say page is temporarily (302) or permanently (301) moved - and set the redirect to your homepage.
Philnext replied on at Permalink Reply
You are wright for most of the changing sites. But my problem is quite different. My site have been indexed by Google while I was changing the structure and the indexed pages have a strange URL (like /my site/99J%OL12%k/ ) which is a temp one. So I need to redirect ALL these pages to the main page because I need to keep the good position of these pages.
olliephillips replied on at Permalink Reply
olliephillips
Still applies. A 301 redirect of the strange URI to the correct URI is what you need to tell the search engines what is what and ensure your visitors on those URIs are sent to the right place. I don't think 404 is the way to go here.

Hope that helps.
Philnext replied on at Permalink Reply
To use 301 I have 2 problems :
1/ I don't know how to use 301 on deleted pages (unless to recreate them)
2/ I don't know all the deleted pages
So the use of 404 is OK for me because it catch all the deleted pages.
WebcentricLtd replied on at Permalink Reply
doing a Google site: check would probably give you the pages that you'd need to redirect.

You'd need to copy and paste these and corss-reference them with a list of the correct URLs and add them to an .htaccess file as 301 redirects.

If it is a lot of URLS it could be time-consuming and tedious through.

If you do try redirecting your 404 and end up accidentally returning a 404 for your homepage it will never get indexed.

I'd create a custom 404 to be honest... if doing the redirects was too difficult.
olliephillips replied on at Permalink Reply
olliephillips
You don't need to recreate the pages you can use .htaccess to redirect the old/missing page to the new one. Bit more complicated if you don't know what pages are missing though.

If the duff links have a particular format/syntax to them you can probably catch them with a regular expression in your htaccess file and 301 them that way - for example your real links won't have a '%' symbol in them. A regex could be used to redirect if % was part of the URI.
Philnext replied on at Permalink Reply
OK thanks for all. I will customize my 404 page...