.oO(mscir)
>I created a protected sub-folder "/archive" under the folder the site
>files reside in. Then I testd whether the 403.html page I made would
>show up correctly if I tried to access the protected folder from my
>browser (not loggin in with an FTP program) as a public user. If I tried
>to access the folder like this I saw the 403 page correctly:
>
>url/archive
>
>But if I tried to access the folder like this (with an ending slash) I
>saw the page I made without the styles in the stylesheet applied:
>
>url/archive/
>
>To fix it, the site host suggested I add a slash before the stylesheet
>name. When I did that the styles were applied correctly in both cases!
>
><link href="/styles.css" type="text/css" rel="stylesheet">
>
>Can any body explain that? [...]
In case of an 403/404/... the response from the server contains the
content of the error page, not a redirect or something like that. So the
browser displays the received content under the URL that caused the
error and will use that(!) URL to resolve any relative URLs inside the
error page.
In your case when you link to the stylesheet with just "styles.css" this
relative address is resolved differently, dependent on how you called
the error-causing page:
*
www.example.com/archive
current directory is the site root /, so all relative URLs will be
resolved to start from there
->
www.example.com/styles.css
*
www.example.com/archive/
current directory now is /archive/
->
www.example.com/archive/styles.css (which will cause a 404 error)
>Is it always recommended that a slash is
>always used to represent the relative url before a stylesheet name -
Yep, at least in this case.
>even if it's in the same folder as the pages that reference it?
It's an issue of how a browser resolves relative URLs.
>Is it
>better to always name the absolute url of the stylesheet? I'm wondering
>if there's a convention, or recommended policy.
I use root-relative URLs in most cases, whether they are really
necessary or not.
Micha