0

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...

f1ames
  • 1,714
  • 1
  • 19
  • 36

1 Answers1

3

In your regex, use a negative look-ahead

RewriteEngine on
RewriteCond %{REQUEST_URI} ^(?!/static/).+ [NC]
RewriteRule (.*) index.php [L]
Jamey
  • 1,595
  • 9
  • 23
  • I tested it on a IIS server with an ISAPI plugin for mod_rewrite. It's supposed to be the same as apache's syntax. If it's no good for you, try without the slash in front of "static". If still no good, I'll retract my answer :-( – Jamey Sep 21 '11 at 16:19
  • Oh, and regardless of whether my rewrite rule works, I'm pretty sure your server hates you. – Jamey Sep 21 '11 at 16:23
  • Ok, it works:D The only thing which bothers me, when this file in static folder exists it works, but if not it redirects to index.php. I thought in non-existsing file case should be 404 or something... – f1ames Sep 21 '11 at 19:51