Hello people,

On my site i am using a .htaccess file with a simple rewrite rule:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^servers/(.*)/ index.php?action=servers&id=$1

Allowing visitors of my site to use www.example.com/servers/1/ - which will grab and display the correct page from www.example.com/index.php?action=servers&id=1

In the index.php file, there are links and stylesheets defined with local paths, for example, <link rel="stylesheet" type="text/css" href="style.css" />

Everything works when people access the index.php directly, however, if they use for example www.example.com/servers/1/, the site will grab the content correctly from index.php (+ variable) but subsequently will fail to load any local paths defined in it. As it now is trying to load the style.css from www.example.com/servers/1/style.css

As it appears now, i am forced to use absolute paths, everywhere. Is there any other solution to this problem?


*EDIT* Sigh, been searching for hours, but somehow always bump to the conclusion a few minutes after posting a thread somewhere. The solution (for me) was HTML's base tag: http://www.w3schools.com/tags/tag_base.asp

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.