404 Redirection

I want to set up a redirection so that all pages that have a 404 error get redirected to the root.

How do I do that, is it htaccess?

Re: 404 Redirection

yes .htaccess. Example:

ErrorDocument 404 http://www.guysonvideo.com/tour/index.php

Re: 404 Redirection

Thanks, sorted.

Re: 404 Redirection

[QUOTE=Seth;30096]yes .htaccess. Example:

ErrorDocument 404 http://www.guysonvideo.com/tour/index.php[/QUOTE]

That solution may create duplicate content problems since all bad URLs on your site will have the same content as your homepage. Not sure how Google would handle that since the response code will be 404. Best to do a little checking first… Better would be to have a separate page with a meta refresh to the home page.

Re: 404 Redirection

Hello All
what are the steps to doing the redirect?

Re: 404 Redirection

I cant quite remember by now but you got to use:

ErrorDocument 404 /tour/index.php

and not the full URL. For some reason its quite important… just cant remember right now why.

And I agree with Rawtop. Be careful with what you use for a 404 page. I would do a custom page rather than a existing page. At least just make sure to title the page as Error 404 if nothing else.

[quote=Seth;30096]yes .htaccess. Example:

ErrorDocument 404 http://www.guysonvideo.com/tour/index.php[/quote]

Re: 404 Redirection

I know I did em in the past but been ages and forgot how to do em agggrrr

Re: 404 Redirection

Welcome Macho,

First of all you need to your server, FTP or SSH.

Look at the root folder on your server. If there isnt any existing htaccess file, you simply create one in Notepad and save it as .htaccess

At the top of the file, just create something like:

 
ErrorDocument 404 /404.html
ErrorDocument 403 /404.html

etc.

Just be aware, a lot of FTP programs will hide that type of file format.

There are lots of resources on how to use htaccess:

http://www.google.co.uk/search?hl=en&q=htaccess

Its a very useful function that can rewrite your URLs, redirct URLs and much more.

[quote=Macho;30102]Hello All
what are the steps to doing the redirect?[/quote]

Re: 404 Redirection

As for google, it doesn’t matter if you use a full URL or just the relative one, you are telling google that the page is 404 (not there) so it knows what to do.

Re: 404 Redirection

For the error page, are we allowed to set it to a URL that’s located on another server or should it be one on the same domain?

Also, what’s the best approach to the error page itself, should it be something simple written in static html, e.g would using php be too taxing on the server if its getting many 404 hits?

Re: 404 Redirection

So Google gets the 404 even though there’s a redirect to the tour? For some reason I thought also that doing a 404 redirect to the tour would result in getting dinged by google.

Re: 404 Redirection

I’ll have to find the article i read about using relative or full url. I’m sure there was a very good reason why not to use the full URL. Not to do with SERPs or SEO but something else…

Ill search around and find it.

Re: 404 Redirection

[QUOTE=gaydemon;30140]I’ll have to find the article i read about using relative or full url. I’m sure there was a very good reason why not to use the full URL. Not to do with SERPs or SEO but something else…

Ill search around and find it.[/QUOTE]

I found this at http://www.htaccesselite.com/htaccess-errordocument-examples-vt11.html:

“Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as “http” in front of it), Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. In addition, if you use a remote URL in an ErrorDocument 401, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, if you use an “ErrorDocument 401” directive then it must refer to a local document.”

I went ahead and made the change to a unique 404 page and am using a server path to be on the safe side. I did the same for other error docs as well. Now I just have to check all my sites… :bang:

Re: 404 Redirection

yes thats it! I knew there was a good reason, just couldnt remember what it was I found, was a while back.

[quote=Seth;30142]I found this at http://www.htaccesselite.com/htaccess-errordocument-examples-vt11.html:

“Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as “http” in front of it), Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. In addition, if you use a remote URL in an ErrorDocument 401, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, if you use an “ErrorDocument 401” directive then it must refer to a local document.”

I went ahead and made the change to a unique 404 page and am using a server path to be on the safe side. I did the same for other error docs as well. Now I just have to check all my sites… :bang:[/quote]

Re: 404 Redirection

aha - i did not know that, thanks!

Re: 404 Redirection

Thanks. So would this work?

ErrorDocument 404 /

Re: 404 Redirection

If you use PHP instead you can detect the error status first and then set where you want it to lead the surfer, and lastly use something like this in the code :

// Dump the HTTP status
header($header);

// Pull in the contents of the file instead of redirecting
echo readfile($_REDIRECT[0]);

That will return the correct error status to the SE’s etc but land your surfer on a page you have specified previously…

(Of course that is just the final tiny part of the code)

Re: 404 Redirection

[QUOTE=gaydemon_jr;30221]Thanks. So would this work?

ErrorDocument 404 /[/QUOTE]

Yes