Welcome to WebmasterWorld Guest from 54.162.167.40

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

404 Missing Page Won't Recognize Style Sheet

     
1:26 pm on Jan 22, 2009 (gmt 0)

5+ Year Member




My site seems to work fine otherwise but I can't get my missing.htm 404 page to recognize the style sheet. It is in the same base directory as my index.htm page and calls the same stylesheet path. I have also tried the direct URL to the style sheet and nothing works.

If it matters, server is Server version: Apache/1.3.34

3:00 pm on Jan 22, 2009 (gmt 0)

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Try adding a base path in your missing.htm page before the stylesheet:

<base href="http://www.example.com/" />

You may need to adjust the path. Alternatively, try using the full path when adding your style.css link. You may also need to adust image urls too in your stylesheet.

dc

4:10 pm on Jan 22, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Also recently discussed here: [webmasterworld.com...]

Jim

4:11 pm on Jan 22, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It really depends on where the 404 comes from. For example, you have the following structure:

mydomain.com
mydomain.com/httpdocs
mydomain.com/httpdocs/index.html
mydomain.com/httpdocs/my-404.html
mydomain.com/httpdocs/css/mycss.css
mydomain.com/cgi-bin/myscript.cgi

If your CSS in the 404 is like this,

<link rel="stylesheet" type="text/css" href="css/mycss.css">

And you try calling a non-existent file in the cgi-bin,

mydomain.com/cgi-bin/nonexistent.cgi

The error actually comes from the cgi-bin directory, so at that point, it's looking for

cgi-bin/css/mycss.css

(You can verify this by checking out your error logs.)

You don't need to do a base href (I find these create more havoc than they help . . . at least for me . . . ) if you simply reference all files relative to the domain root, everything will connect properly:

<link rel="stylesheet" type="text/css" href="/css/mycss.css">

That leading forward slash means "start at the domain root" (mydomain.com/httpdocs.) So wherever you move this 404 page, it will connect with mydomain.com/httpdocs/css/mycss.css.

The same is true of all your selectors in the css,

background:url(/images/bg.gif);

and images in your documents

<img src="/images/myimage.gif">

Forming this habit allows you to move files anywhere on your system without having to modify paths. for this file,

mydomain.com/httpdocs/some-directory/some-other-directory/im-buried.html

You would have the same path,

<link rel="stylesheet" type="text/css" href="/css/mycss.css">

as this file.

mydomain.com/httpdocs/index.html

Move it wherever you like, it will always find the CSS.

Oops, simul-post, JD has it!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month