开发者

All except one directory in mod_rewrite

开发者 https://www.devze.com 2023-03-26 09:25 出处:网络
I have little problem with mod_rewrite and I absolutely have no idea what to do with this. I have this rule:

I have little problem with mod_rewrite and I absolutely have no idea what to do with this.

I have this rule:

RewriteRule ^([\w/]*)$ index.php/?page=$1 [L]

This rule works for every directory. I want this rule to work but except one directory - "test". What I need to change in this rule?

For example: I want this URLS redirecting to index.php/?page=$1: http://test.com/account http://test.com/dog http://test.com/cat And I 开发者_如何学Cwant only this URL not redirecting to index.php/?page=$1: http://test.com/test (only test)

Thanx!


Add this RewriteCond line just before your rewrite rule, so it looks like this:

RewriteCond %{REQUEST_URI} !^/test(/|$)
RewriteRule ^([\w/]*)$ index.php/?page=$1 [L]

If (for some strange reason) it does not work -- please provide an example of working URL (the one that needs to be redirected) and the one that should not.

0

精彩评论

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