除mod_rewrite中的一个目录外的所有目录 [英] All except one directory in mod_rewrite
问题描述
我对mod_rewrite没什么问题,我绝对不知道该怎么办。
I have little problem with mod_rewrite and I absolutely have no idea what to do with this.
我有以下规则:
RewriteRule ^([\w/]*)$ index.php/?page=$1 [L]
此规则适用于每个目录。我希望此规则有效,但一个目录- test除外。
我需要在此规则中更改什么?
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?
例如:
我希望此URL重定向到index.php /?page = $ 1:
http://test.com/account
http://test.com/狗
http://test.com/cat
而且我只希望此URL不重定向到index.php /?page = $ 1:
http://test.com/test (
感谢!
推荐答案
添加此 RewriteCond 行位于您的重写规则之前,因此如下所示:
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.
这篇关于除mod_rewrite中的一个目录外的所有目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!