1

I have used Redirect rules to decode queries like

user/34 to user.php?id=34

The problem is now using relative urls in user.php image.png is now searched relatively to not existing folder user

what I want now is to attach / to each relative path.

I have tried

RewriteCond %{REQUEST_URI} !^/(.*)$
RewriteRule ^(.*)$ /$1

But this does not work

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
bitluni
  • 219
  • 1
  • 7

1 Answers1

2

This is not possible: A relative path is made into an absolute path in the browser.

What arrives on server side is the absolute URL

http://example.com/user/34/images/image.png

The best fix would be to use absolute paths in your HTML markup:

<img src="/images/image.png">

You could also use the <base> tag, but I personally dislike the practice because of the confusion it tends to create. Using absolute paths from the start would be the cleanest way.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Currently I started to replace all relative paths be absolute once and for those I didn't do yet I use the . I thought about redirect all requests to root except for existing directories. maybe somhow overload .htaccess then in the subfolders – bitluni Apr 26 '11 at 06:43