Forum Moderators: phranque

Message Too Old, No Replies

Custom 404 Page not Found

How should this be done?

         

Marcia

11:14 am on Aug 31, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


There's a 302 being returned, not a 404 with this in .htaccess:

ErrorDocument 404 http://www.sitename.com/nofile.html

How should that be done instead?

Brett_Tabke

11:28 am on Aug 31, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Interesting subject. A very common problem. Hopefully there is a solution other than this: (this isn't perfect ;-)

Make sure your destination 404 page has 404 File Not Found in the title. Se's will find that. I don't think there is much else you can do.

Unfortunately, some browsers will cache the original redirect. That's not a problem if the original request was to a static page. The caching, can lead to problems if the original request (that errored) was to a dynamically generated page. Users won't be able to get back to the original page that generated the error on some browsers without clearing the cache. The moral is, to make sure your 500 errors go somewhere besides the default 404 page.

Marcia

11:42 am on Aug 31, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, it's got "Error 404 page not found - custom designed by (keyword phrase)...and it's sitting at #5 at Lycos for the keywords. Talk about feeling stupid. :)

I was told this is dangerous, because if it's picked up every time there's a 404 I could get zapped for duplicate content, because of the 302. Nothing's dynamically generated, so that's not a problem.

Gorufu

12:14 pm on Aug 31, 2001 (gmt 0)

10+ Year Member



> Hopefully there is a solution other than this: (this isn't perfect ;-)

There is a simple solution. Relative URL's will return 404 errors.

When a full URL is used a 302 redirect is returned. The incorrect URL is replaced with the redirect URL

[31/Aug/2001:21:58:23 +1000] "GET /dir/doit HTTP/1.0" 302 223
[31/Aug/2001:21:58:24 +1000] "GET /missing.html HTTP/1.0" 200 713

When a relative URL is used a 404 error is returned. The incorrect URL remains and the error page is displayed

[31/Aug/2001:22:01:02 +1000] "GET /dir/doit HTTP/1.0" 404 713

Images will be broken for 404 relative URL's. This can be fixed by using full URL's for images in the error page.

Marcia

12:38 pm on Aug 31, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Changed it to:

ErrorDocument 404 /nofile.html

It returned a 500 without the forward slash, so I added it and it works fine - checked, and it's a 404.

Thanks!

(fixed typo)

(edited by: Marcia at 12:50 pm (gmt) on Aug. 31, 2001

Gorufu

12:40 pm on Aug 31, 2001 (gmt 0)

10+ Year Member



Hi Marcia,

Replace

ErrorDocument 404 [sitename.com...]

with

ErrorDocument 404 /nofile.html

Marcia

12:48 pm on Aug 31, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, typo - left out the 404 when I posted. Thanks again.

Marcia

6:17 am on Sep 3, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you Patric, and welcome to WebmasterWorld. Good info there, good to know because most people don't change defaults.