Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have:
RewriteRule ^([^.]+)/([^.]+)$ ?language=$1&title=$2 [NC]

rewrites to

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

Re: RewriteRule

betty escribió:
Quoted text here. Click to load it

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
several alternatives:

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 ;-)

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Re: RewriteRule

Thanks to all for helping out.

I use now:
<base href="http://
  <? echo $_SERVER['SERVER_NAME'];
     echo substr($_SERVER['SCRIPT_NAME'], 0,
strrpos($_SERVER['SCRIPT_NAME'], '/'));
/" />
<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.


Re: RewriteRule

betty wrote:
Quoted text here. Click to load it

I have had this problem ...

Just use <base> html tag and problem should go away :-) Or use full URI in your
css include path etc.

Site Timeline