Modrewrite error - 404 error

I have this url

http://sites.com/driver.php?n=spa

      

I did it like this:

http://sites.com/driver/spa

      

Here is the .htaccess code I am using.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^driver([^/]*)$ driver.php?n=$1 [L,QSA]

      

it works but for example all my files including scripts and stylesheets don't work because it adds to / driver to all urls like this example

http://sites.com/style.css

      

to

http://sites.com/driver/style.css 

      

.. I can avoid by writing full script and stylesheet urls, but is there any other way? I can do this, but I have over 40 script and style urls and it will take me a while to rewrite them with a full url.

+1


source to share


1 answer


The reason for this issue is the use of relative resource links in CSS / js / image. To fix this problem, you can sdd this in the HTML header of your page:

<base href="/" />

      



This week tell the browser to add / all, it finds the relative path resource on the page.

+1


source







All Articles