简体   繁体   English

mod_rewrite规则:如果URL包含某个原始字符串

[英]mod_rewrite rule: if URL contains a certain string to orginal

My client keeps editing the structure of the navigation in the website, which is leading to some mod_rewrite issues. 我的客户一直在编辑网站中导航的结构,这导致了一些mod_rewrite问题。 How could i make this rule in apache: 我该如何在Apache中制定此规则:

the actual ur is 实际的你是

/AuthCont?FORMSGROUP_ID__=AuthenticationFG&__START_TRAN_FLAG__=Y&FG_BUTTONS__=LOAD&ACTION.LOAD=Y&AuthenticationFG.LOGIN_FLAG=1&T_ID=ND

but if user manually changes AuthenticationFG.LOGIN_FLAG=1 to AuthenticationFG.LOGIN_FLAG=2 or AuthenticationFG.LOGIN_FLAG=3 it should rewrite to actual AuthenticationFG.LOGIN_FLAG=1 kindly help 但是,如果用户手动将AuthenticationFG.LOGIN_FLAG=1更改为AuthenticationFG.LOGIN_FLAG=2AuthenticationFG.LOGIN_FLAG=3 ,则应将其重写为实际的AuthenticationFG.LOGIN_FLAG=1

From: https://wiki.apache.org/httpd/RewriteQueryString 来自: https : //wiki.apache.org/httpd/RewriteQueryString

Modifying the Query String: Change any single instance of val in the query string to other_val when accessing /path. 修改查询字符串:访问/ path时,将查询字符串中val的任何单个实例更改为other_val。 Note that %1 and %2 are back-references to the matched part of the regular expression in the previous RewriteCond. 请注意,%1和%2是对先前RewriteCond中正则表达式匹配部分的反向引用。

RewriteCond %{QUERY_STRING} ^(.*)val(.*)$
RewriteRule /path /path?%1other_val%2

So you could try for example: 因此,您可以尝试例如:

 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

EDIT 编辑

hrmm okay try this: 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM