开发者

mod_rewrite - all to index except static folder

开发者 https://www.devze.com 2023-04-06 16:50 出处:网络
I\'ve been trying and trying and can\'t find the solution, which surely is pretty easy. I have rule RewriteEngine on

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消