f1ames
f1ames

Reputation: 1734

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$
RewriteRule (.*) index.php [L]

or

RewriteEngine on
RewriteRule static/(.*) static/$1 [L]
RewriteRule (.*) index.php [L]

And some other variations but nothing seems to work...

Upvotes: 0

Views: 1527

Answers (1)

Jamey
Jamey

Reputation: 1633

In your regex, use a negative look-ahead

RewriteEngine on
RewriteCond %{REQUEST_URI} ^(?!/static/).+ [NC]
RewriteRule (.*) index.php [L]

Upvotes: 3

Related Questions