Forum Moderators: phranque

Message Too Old, No Replies

Custom 404 error page not displaying correctly

         

pwdruk

1:14 pm on Feb 3, 2012 (gmt 0)

10+ Year Member



Hi All,

Newbie to this forum and complete noob to web design. Got asked by my brother-in-law to update his site and so have been tinkering with it.

I've updated the site with new content, which resulted in other sites still linking to old, non-existing content and thus, 404 errors.

I've created the following basic .htaccess file containing only:

ErrorDocument 404 /not_found.php


I've created a custom 404 not_found.php and placed it in the same directory. All seems to work well when the wrong url is entered eg.:
URL:
[coltgap.com ]

as opposed to:

URL:
[coltgap.com ]

However, the custome 404 page does not display correctly when another directory is added to the URL, eg:
[coltgap.com ]

It is clearly the same custom 404 page displayed in both instances, but I am clueless as to why it won't display it correctly when it's 'invoked' (for the lack of a better description) from a non-existant directory.

Any help would be sincerely appreciated.

penders

2:22 pm on Feb 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your 404 page seems to display OK for me in both cases. I'm guessing that you may not have had full paths to your CSS/JS/IMG files... these need to be absolute (or root-relative) paths.

BUT... if pages have moved to a new URL, then you should be redirecting from the old to the new, with a permanent 301 redirect, so search engines (and users) will pick up the new content. You should not return a 404 in this instance if you can help it.

pwdruk

2:50 pm on Feb 3, 2012 (gmt 0)

10+ Year Member



Thank you for the response. I am at a loss, I did not have full paths to my CSS/JS/IMG files until yesterday. After fixing the full paths, the links from the incorrectly displayed custom 404 page worked for the first time, but the page itself still displayed incorrectly.

I checked the link again after your response, as well as all other backlinks, and the custom page now displays correctly in all scenarios.

I have not done anything to it since then. Regardsless, it seems sorted now.

A very usefull forum indeed, thanks!

lucy24

8:15 pm on Feb 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



but the page itself still displayed incorrectly

:: peering into crystal ball ::

Did/does your error page contain relative links to related files such as images or stylesheets?

g1smd

9:10 pm on Feb 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your browser may have cached incorrect views.

Be sure that links to images and stylesheets begin with a leading slash and specify the full path to the file.

You cannot use relative links because the 404 error page is served at the non-valid URL, and that could be any number of folders deep.