2014-11-21 70 views
0

我的客戶端不斷編輯導航的結構在網站,這是導致一些mod_rewrite問題。我如何才能讓這條規則在阿帕奇:mod_rewrite規則:如果URL包含特定的字符串到原始

實際UR是

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

但如果用戶手動更改AuthenticationFG.LOGIN_FLAG=1AuthenticationFG.LOGIN_FLAG=2AuthenticationFG.LOGIN_FLAG=3應該重寫實際AuthenticationFG.LOGIN_FLAG=1好心幫

回答

0

來源: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] 
+0

我認爲這會工作,讓我知道如果沒有。 – DrewT 2014-11-21 04:02:05

+0

它不工作其不重寫友善幫助 – 2014-11-21 04:35:13

+0

它不能工作任何替代 – 2014-11-21 12:47:48

相關問題