views:

36

answers:

2

Hi!

I have some magic stuff in my htaccess. It works very well but I don't know how

RewriteRule ^[^_+/]. index.php

I think it says that all requests should go through index.php no matter which directory the visitor ask for. So far so good. However images, css files, js files etc should of course not be parsed in index.php. Can I exclude certain directories from the above rule? Like /img, /css and /js

Other suggestions?

Thanks in advance

+4  A: 

you can exclude existing files and directories

RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d

by placing this before your rule

Col. Shrapnel
I guess it'll work. However I would feel more secure with deny all and have exception from that with specific paths. I'll use your solution in the meantime
Anders
A: 

You can avoid requests to certain paths by using a simple RewriteCond...

RewriteCond ${REQUEST_URI} !^css
RewriteCond %{REQUEST_URI} !^img
RewriteCond %{REQUEST_URI} !^js
# or alternatively just
RewriteCond ${REQUEST_URI} !^(css|img|js)
Cags
Thanks man! Works like a charm. I had to add a slash prior to the directory name though.
Anders