Forum Moderators: phranque

Message Too Old, No Replies

htaccess ErrorDocument

completely redirect

         

Doood

6:59 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



I'm using this to redirect all 404 to a certain page on my site,

ErrorDocument 404 /error.php

If they go to /nopage.php they see /error.php but the url bar still shows /nopage.php. If they go to /nofolder/nopage.php they still see the /error.php page but the images and external style sheet won't work cause there in /nofolder.

How do completely redirect them to the 404 /error.php page?

jdMorgan

8:28 pm on Feb 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As described in the Apache ErrorDocument description, you can completely redirect by using a canonical URL in ErrorDocument, but I *strongly* recommend you don't do that. It can seriously mess up your search engine listings due to duplicate-content 'penalties' -- All pages redirected to /error.php will appear to be duplicates, and you will not be providing the spider with a 404 response code to 'explain' that fact.

Instead, best practice would be to change the image references in error.php from <img src="some_image.gif"> to <img src="/some_image.gif">. This will force the relative image URLs to be resolved relative to the root of your site, instead of the current directory.

Jim