ErrorDocument 404

I want to redirect visitors to custom 404 error page, for example, I move my website content around but wish to redirect traffic to the new page from the old location.

I made this line in my .htaccess file,

ErrorDocument 404

it seems to be working fine. But I want to know if I am doing it correctly if you can advise me please.

do i have any down side with this line for search engines?

I came across this tutorial online, but I dont quite get it about sending 301 (permanently moved) headers…

many thanks,

You have no file extension, is this just a typo?

I use

ErrorDocument 404 /404.php

in the .htaccess of my root directory and it works fine across the site.

I may be corrected on this but a 404 not found is, well a 404 not found, to a search engine no matter how you dress it up so you should not be penalised any more or less for having content that cannot be found.

A 301 redirect will send users and search engines to a new page of your choosing when they try to hit on a page that you have moved or deleted. You can instigate the page to go to, and from which page, using .htaccess. This redirect is seen as permanent and not an error and that is an important difference.


thanks for the reply.

I have this line below in my .htaccess as well before ErrorDocument,

RewriteRule ^([a-zA-Z0-9\\-]+)/?$  index.php?pg=$1 [QSA]

so will be rewritten as,

now i have changed the ErrorDocument line to,

ErrorDocument 404 /index.php?pg=404error

so it won’t have this on the url when there is a broken link - I hope I am doing this correctly!

it will be redirected to the custom 404 error page, if you simply type in,

or anything else that does not exist on my site


hi thanks for this idea. the trouble is I don’t know what pages people would order from my site, so i think using apache is a better option for me.


You’ll want to read this page if you’re thinking of using any other server errors or using any absolute redirects (also, ColinHughes is correct in that you needn’t an absolute url, relative is fine):

thank you for the link. yes i’m using relative url for 404 error now. thanks :slight_smile: