问题
I have this url
http://sites.com/driver.php?n=spa
I made it look like this
http://sites.com/driver/spa
here is .htaccess code I am using..
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^driver([^/]*)$ driver.php?n=$1 [L,QSA]
it's working but for instance all my files including scripts and stylesheets are not working because it's adding 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 the full script and stylesheet urls but is there any other way? I can do this but I have more than 40 script and stylesheet urls and it will take me time to rewrite them all with the full url.
回答1:
Reason of this problem is use of relative links on CSS/js/image resources. To fix this issue you can sdd this in your page's HTML header:
<base href="/" />
This week tell browser's to append a / everyone it finds a relative path resource in the page.
来源:https://stackoverflow.com/questions/27280890/modrewrite-issue-404-error