Print Reseller Scheme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom 404/Error Page

Discussion in 'Website Coding & Programming Forum:' started by Tony Hardy, Aug 16, 2011.

  1. Tony Hardy

    Tony Hardy Well-Known Member

  2. JohnRoss

    JohnRoss Member

    The page works, nothing on it does. It is trying to find everything in the wrong places. Read up on "absolute" and "relative" URLs and come back. I'll give you a clue - your css file is not at "http://www.tastytreats.org.uk/thispagedoesnotexist.html/css/styles.css" but at "http://www.tastytreats.org.uk/css/styles.css."
     
  3. Tony Hardy

    Tony Hardy Well-Known Member

    I understand absolute and relative URL's, yet I still don't understand what's causing the error?
    My NotFound page works when it doesn't have a slash at the end, but when it does it doesn't? How can an absolute/relative issue be causing this?
     
  4. dedwardp

    dedwardp Member

    I think that by adding the / at the end, the page is loading as though it is a new directory. Therefore, from the new directory, the css file would then be found at "../css/style.css" say, rather than just "css/style.css".
     
  5. Tony Hardy

    Tony Hardy Well-Known Member

    So is there a fix? Or because it'll always think it's looking in a new directory with a slash then it'll always produce an error?
     
  6. Tony Hardy

    Tony Hardy Well-Known Member

    Well, I've got it to work, by putting the "/" in the link to the CSS. But now, none of the links work?
     
    Last edited: Aug 16, 2011
  7. dedwardp

    dedwardp Member

    Not completely sure on that one, sorry!
     
  8. djb

    djb Member

    You need to make all the links on the 404 page absolute rather than relative.

    So the link to the homepage would be

    Code:
    http://www.tastytreats.org.uk/index.html
    rather than just

    Code:
    index.html
    That way, no matter at what directory level the 404 page is showing at it always knows exactly where everything is by following the absolute, unchangeable web address.*

    *I think
     
    Last edited: Aug 16, 2011
  9. Tony Hardy

    Tony Hardy Well-Known Member

    I think I've done it, I also had to have the link to the .css page with a slash in front of it so it could find that too at every level (I think)?

    Is it working for you guys? :)
     
  10. dedwardp

    dedwardp Member

    Works for me! :)
     
  11. djb

    djb Member

    Yep works for me to. What about having the link to the stylesheet as an absolute link too?

    And the two links in the middle still need changing but you’ve probably seen that already.
     
  12. Tony Hardy

    Tony Hardy Well-Known Member

    I've just seen the two in the middle there haha.
    I'll also do the sitemap link, forgot all about that.

    Are the absolute links only necessary on this page because it can occur in any directory? Whereas the other pages can use relative links because they'll always be on the same level on the site?
     
  13. djb

    djb Member

    Exactly. :icon_smile:
     

Share This Page