2012-08-08 16 views
0

我已經在httpd.conf文件中編寫了一些規則。它工作正常。我想寫一個RewriteCond,它應該匹配第一個和第二個參數,並且如果它的匹配不應該重定向。如果某些RewriteCond匹配,請不要重定向

如果URL是手機/登錄或移動/管理重定向不應該發生,我該怎麼做。

- 更新 -

RewriteCond %{HTTP_USER_AGENT} "!(android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile|Nokia*| Opera*)" [NC] 
RewriteCond $1 !web 
RewriteCond $2 !login 
RewriteCond $2 !admin 
RewriteRule ^(.*)$ /web/index.php [R,L] 

這裏$ 2部分不適合我的工作。

+0

如果你包含你的'httpd.conf'文件的相關部分可能會有所幫助。 – megaflop 2012-08-08 10:07:19

回答

0

在您的RewriteRule的模式開始處添加!字符。

請參閱the documentation瞭解更多信息。

更新

$ 2不適合你,因爲你的重寫規則模式只有一組捕獲括號中。這可能是你要找的東西:

RewriteCond %{HTTP_USER_AGENT} "!(android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile|Nokia*| Opera*)" [NC] 
RewriteCond $1 !(web|mobile/login|mobile/admin) 
RewriteRule ^(.*)$ /web/index.php [R,L] 
+0

查看代碼更新 – Hacker 2012-08-08 12:06:38

+0

我的更新有幫助嗎? – megaflop 2012-08-15 08:55:33