[英]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.