Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
November 9, 2008, 2:05 pm
rate this thread
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&title=$2 [NC]
rewrites domain.com/index?language=en&title=home to domain.com/en/home
Problem: to link to css-files, images etc I have to use '../' to go
into an upper folder, while this shouldn't be necessary. It is because
of de 'folder' 'en' which is in the address field of the browser.
Is there a possibility to resolve this?
Using '/' does not help, because the web app is not in the root.
Thanks in advance
November 10, 2008, 8:37 am
The browser doesn't know/care about the server's disk layout. If you add
slashes to the URL you *are* adding directory levels. So you have
1. Replace slashes with anything else:
2. Fix your relative URLs, adding "../" as you said; it *is* necessary.
3. Build absolute URLs. PHP is a programming language, it should not be
a big issue to replace / with the appropriate value for your system ;-)
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
I use now:
<? echo $_SERVER['SERVER_NAME'];
echo substr($_SERVER['SCRIPT_NAME'], 0,
<link rel="stylesheet" href="css/main.css" type="text/css" />
Using only <base /> is not good: when moving the website to another
folder, I have to change <base />.
Using only PHP to find the root folder, isn't good too: I have to put
it everywhere in the file when linking to a file like css or image.
SO I'm using a combination of both.
Is using $_SERVER['SERVER_NAME'] and $_SERVER['SCRIPT_NAME'] the