PDA

View Full Version : path !


angiras
05-05-2003, 05:37 PM
is there a good way for all browsers to avoid ../../

<link href="styles/any.css" rel="stylesheet" type="text/css" media="all">

<link href="../styles/any.css" rel="stylesheet" type="text/css" media="all">

to find im any case the folder styles ?

thank you

giz
05-11-2003, 02:16 PM
<link href="/first/slash/defines/path/from/the/top/of/the/site/styles/any.css" rel="stylesheet" type="text/css" media="all">

angiras
05-11-2003, 07:59 PM
you mean


/siteRoot/folder/any.css ?

it doesn't work

Alex Vincent
05-11-2003, 09:31 PM
giz: I'm fairly certain that would not work.

angiras: the kinds of URLs you give are considered relative URLs. The user-agent (a fancy word for browser in this case) would then compute an absolute URL (http://www.foo.com/bar/whatever) from that.

Your best bet is to use an absolute URL, complete with http:// protocol prefixed.

liorean
05-11-2003, 10:40 PM
In fact, the user agent (unless it's a proxy) always converts it to an absolute path (also called root relative) and sends the domain in the Host header. (Does so also with absolute URIs.)

So, '/path/file.ext' should work, given the file exists in the same domain. For example, when I was hosted at 'http://members.evolt.org/liorean/', I had stylesheets in the subdirectory 'css', so I referred to them using '/liorean/css/file.ext'. Just don't forget, that you count from your domain, not your site root. If your site root is (like mine was) a directory in the domain, you must remember to include that directory too in your links.

angiras
05-12-2003, 06:54 AM
yes that's what I mean

at home it is

/localhost/styles/any.css

on my distant server

/angiras/styles/any.css

the problem stays the same, I solved it of course with 2 different configuration files, but it is server side code and not hTML, a lot of staff for only to find javascript styles and images !!

with ASP NET it's easy (but server side)

~/styles/any.css , but you must add a runat=server

.....then HTML as no solution

liorean
05-12-2003, 11:22 AM
Root relative is designed for ftp, http, https etc. protocols, not file protocol. It can be used with the file protocol, especially on linux/unix systems where you haven't got drive letters to worry about, but there it is system root relative, not domain relative. If you use the same structure on your harddrive as you use on your domain, it should work.

An alternative is that you use a local http server, or use your hosts file to map 'angiras' to 127.0.0.1 (localhost).