All except one directory in mod_rewrite

被刻印的时光 ゝ 提交于 2019-12-23 05:27:46

问题


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 want only this URL not redirecting to index.php/?page=$1: http://test.com/test (only test)

Thanx!


回答1:


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.



来源:https://stackoverflow.com/questions/6942652/all-except-one-directory-in-mod-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!