On the one hand mod_rewrite allows me to make userfriendly urls redirecting requests to proper script but on the other I can't use relative links because they will point at nonexistent files.
A little example:
mod_rewrite redirects request
http://site.ru/param/one/page.html
at http://site.ru/script.php
while I have "myimg.jpeg" file at the same folder I can't use relative link <img src="myimg.jpeg />
cause in that case the browser will try to load img from the "http://site.ru/param/one/myimg.jpeg" address.
While using mod_rewrite what is the common practice to render right path to the img/css/js files?
I have 2 ideas about the realization:
1) to add base tag like that <base href="http://site.ru/" />
2) to define a variable with the baseUrl and then use it while rendering src attributes like that:
$baseUrl = 'http://site.ru/';
...
echo '<img src="' . $baseUrl . 'myimg.jpeg" />
Which is the best solution and are there any other ways to solve the problem?