[英]mod_rewrite rule: if URL contains a certain string to orginal
我的客户一直在编辑网站中导航的结构,这导致了一些mod_rewrite问题。 我该如何在Apache中制定此规则:
实际的你是
/AuthCont?FORMSGROUP_ID__=AuthenticationFG&__START_TRAN_FLAG__=Y&FG_BUTTONS__=LOAD&ACTION.LOAD=Y&AuthenticationFG.LOGIN_FLAG=1&T_ID=ND
但是,如果用户手动将AuthenticationFG.LOGIN_FLAG=1
更改为AuthenticationFG.LOGIN_FLAG=2
或AuthenticationFG.LOGIN_FLAG=3
,则应将其重写为实际的AuthenticationFG.LOGIN_FLAG=1
来自: https : //wiki.apache.org/httpd/RewriteQueryString
修改查询字符串:访问/ path时,将查询字符串中val的任何单个实例更改为other_val。 请注意,%1和%2是对先前RewriteCond中正则表达式匹配部分的反向引用。
RewriteCond %{QUERY_STRING} ^(.*)val(.*)$
RewriteRule /path /path?%1other_val%2
因此,您可以尝试例如:
RewriteCond %{QUERY_STRING} ^(.*)LOGIN_FLAG=2(.*)$
RewriteCond %{QUERY_STRING} ^(.*)LOGIN_FLAG=3(.*)$
RewriteCond %{QUERY_STRING} ^(.*)LOGIN_FLAG=4(.*)$
# and so on for all the numbers...
# then:
RewriteRule /AuthCont /AuthCont?%1LOGIN_FLAG=1%2
编辑
hrmm好的,试试这个:
RewriteCond %{QUERY_STRING} ^(.*)LOGIN_FLAG=(.*)$
RewriteRule ^(.*)$ http://your_domain_here.com/AuthCont?FORMSGROUP_ID__=AuthenticationFG&__START_TRAN_FLAG__=Y&FG_BUTTONS__=LOAD&ACTION.LOAD=Y&AuthenticationFG.LOGIN_FLAG=1&T_ID=ND? [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.