Forum Moderators: phranque

Message Too Old, No Replies

htaccess ErrorDocument 404

ErrorDocument gives a 302 error - I need a 301

         

Highlighter

10:46 am on Feb 21, 2005 (gmt 0)

10+ Year Member



Hi

I am sorry if this subject has already been covered before but I have searched a number of threads and still cannont find what I am looking for.

I am using a ErrorDocument 404 in my htaccess file to redirect a non existent page to a useful page for the user.

This works fine except it gives a 302 Page found and search engines do not remove the URL from their directories.

As I am updating product lines regularly, many pages are deleted on updates and I need to give a 301 on 404 errors.

I am not into scripting and wondered if it can be done as a Redirect permanent / in the htaccess file to cover any 404 error to go to a designated file for the site or a directory error page.

I am sure in the last google shake up this has affected my PR which reduced by 1 as so many pages get directed to, and contain the same information, yet still registered on google and other search engines as the old URL.

Any help on this would be appreciated.

all the best
Ken

jdMorgan

12:13 am on Feb 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ken,

Welcome to WebmasterWorld!

Check the ErrorDocument [httpd.apache.org] documentation in Apache core -- You will find that it requires a local URL-path. If you use a canonical URL, you will get a 302 redirect.

Use ErrorDocument /local_path/to/file.html
Not ErrorDocument http://example.com/path/to/file.html

Jim

Highlighter

9:29 am on Feb 24, 2005 (gmt 0)

10+ Year Member



Thank you Jim

I used to use local path and I am sure I had the same 302 error report.

I will change it back to local and monitor the results.

Thanks again
Ken

jdMorgan

1:46 pm on Feb 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is not a matter of chance -- the documentation cited above clearly states that using a canonical URL in an ErrorDocument directive will result in a redirect, rather than the desired error response code.

Also, there's no need to "monitor" this. You can test it right now using the WebmasterWorld server header checker [webmasterworld.com], and note the results of requesting URLs that will trigger particular errors. No need to worry about this for more than a few minutes...

If you're still getting a 302 after correcting the ErrorDocument directives, then the problem is likely to be a mod_rewrite, mod_alias, or script-based redirect in addition to the original ErrorDocument problem.

Jim

Highlighter

1:48 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



Hi Jim

Thanks - it worked and I am now getting a 404 error on the logs

Thanks again

If you want any tips on SEO
Just ask and if I know I will certainly do my best to help.
Ken

Highlighter

1:56 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



PS - I have bookmarked the header tool

It is better than the one I have been using.

I will certainly have a wonder around this great site.

Thanks again
Ken