Reputation: 11362
Noob in mod_rewrite here...I'm developing a new site and using mod_rewrite.
The problem is, when I activate my rules in .htaccess, my links to CSS files and images become unreadable.
For example, I had this: http://www.dico2rue.com/dictionnaire.php?idW=675&word=Resto-basket That I transformed to this: http://www.dico2rue.com/dictionnaire/675/Resto-basket
I know it's probably because the browser is looking for the CSS file in the http://www.dico2rue.com/dictionnaire/675/css/general.css instead of the base directory, but I was hoping there was a way to to leave physical files alone, and only parse other URLs in order to avoid full paths (which apparently slows down downloas speed...?...).
thanks.
Upvotes: 0
Views: 154
Reputation: 631
This problem doesn't have anything to do with mod_rewrite; you just need to provide a valid URL to your CSS file in the src attribute of your link tag. The relative URL you probably want to use is "/css/general.css". See the relative URL rfc.
On another note, your thinking about mod_rewrite might be a little off. In your example you are actually providing a resource in the /dictionnaire/675/ path of your server. The fact that you are using mod_rewrite to do it instead of some other method makes no difference.
Upvotes: 1
Reputation: 32158
you need to add these lines to check if it's not a file or directory right before the rewrite rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Upvotes: 0