mod_rewrite - all to index except static folder
I've been trying and trying and can't find the solution, which surely is pretty easy. I have rule
RewriteEngine on
RewriteRule (.*) index.php [L]
So it redirects all urls to index.php, now I want all files expect this in static folder to be redirected, so urls like domain.com/static/... would not be redirected. I tried for example:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^static$
Rewri开发者_高级运维teRule (.*) index.php [L]
or
RewriteEngine on
RewriteRule static/(.*) static/$1 [L]
RewriteRule (.*) index.php [L]
And some other variations but nothing seems to work...
In your regex, use a negative look-ahead
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(?!/static/).+ [NC]
RewriteRule (.*) index.php [L]
精彩评论