custom SHTML 404

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    custom SHTML 404

    I've made some basic customer error messages to display to the user if
    they type the URL in wrong and its works fine for bad URLS of the form



    Problem is if the bad URL they type has an several addional folder on
    it i.e.



    Then my custom 404 error cannot display the website logo at the top
    because its looking in the ../images folder but Im thinking it would
    then have to be ../../images?

    But I cant change the code to ../../images because then



    wouldnt load the pictures instead.

    Is there a way ensure my logo is at the top regardless of how many
    subfolders the user tries to type?
  • Jim Dabell

    #2
    Re: custom SHTML 404

    David wrote:

    [snip][color=blue]
    > Is there a way ensure my logo is at the top regardless of how many
    > subfolders the user tries to type?[/color]

    Yes, refer to the images relative to the root:

    <img src="/images/..."...

    --
    Jim Dabell

    Comment

    • Brian

      #3
      Re: custom SHTML 404

      David wrote:[color=blue]
      > customer error messages to display to the user if they type the URL
      > in wrong and its works fine for bad URLS of the form
      > www.google.com/bad.htm[/color]

      Best to use example.com for examples like this.

      [color=blue]
      > if the bad URL they type has an several addional folder on it i.e.
      > www.google.com/foo/bar/bad.htm
      >
      > Then my custom 404 error cannot display the website logo at the top
      > because its looking in the ../images
      >
      > But I cant change the code to ../../images because then
      > www.google.com/bad.htm wouldnt load the pictures
      >
      > Is there a way ensure my logo is at the top[/color]

      Well, you can make sure that the logo image file can be found, at any
      rate.
      [color=blue]
      > regardless of how many subfolders the user tries to type?[/color]

      2 choices:

      (1) follow Jim Dabell's advice (use src="/images/foo.gif" instead of
      src="../images/foo.gif")

      (2) use the base href in the error documents so that, no matter which
      directory produces a 404error.html document, the relative urls resolve
      to the same file.

      I'd recommend (2) even if you also do (1), since using base href also
      allows you to put links on the error page so that visitors who get an
      error can easily go to other resources on your site.

      --
      Brian
      follow the directions in my address to email me

      Comment

      Working...