homepage Welcome to WebmasterWorld Guest from 54.227.89.236
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
404 Missing Page Won't Recognize Style Sheet
ctmtb




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


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

 

dreamcatcher




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

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

jdMorgan




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

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

Jim

rocknbil




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

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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved