简单的Htaccess问题

时间:2011-05-06 06:50:35

标签: .htaccess

RewriteEngine on

# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{THE_REQUEST} \?abc=xyz(&(app=([a-z]+))) #i don't know it is right or wrong

########LOGIN########
RewriteCond %{THE_REQUEST} \?event_id=156&rp=([a-zA-Z0-9=]+)
RewriteRule ^events/login.php$ http://www.xyz.com/is2011/login.php?rp=%1 [R=301,L]

########SEARCH########SEARCH########################
RewriteCond %{THE_REQUEST} \?search=([a-z]+)&event_id=156&submit=Search
RewriteRule ^is2011/([a-z]+).php$ http://www.xyz.com/is2011/$1.php?search=%1 [R=301,L]

当且仅当查询字符串中有app = xyz时,我才想跳过上面的重写规则。

1 个答案:

答案 0 :(得分:0)

将是:

RewriteEngine on

# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{THE_REQUEST} \?abc=xyz(&(app=([a-z]+))) #i don't know it is right or wrong
RewriteRule ^(.*)$ - [skip=2]

########LOGIN########
RewriteCond %{THE_REQUEST} \?event_id=156&rp=([a-zA-Z0-9=]+)
RewriteRule ^events/login.php$ http://www.xyz.com/is2011/login.php?rp=%1 [R=301,L]

########SEARCH########SEARCH########################
RewriteCond %{THE_REQUEST} \?search=([a-z]+)&event_id=156&submit=Search
RewriteRule ^is2011/([a-z]+).php$ http://www.xyz.com/is2011/$1.php?search=%1 [R=301,L]

我添加的重写规则不会在其RewriteCond匹配的查询字符串中进行任何替换。跳过标志会跳过下一个 num 规则,在本例中为两个。请参阅http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule上的RewriteRule指令文档。