2016-11-26 127 views
0

我試圖爲我的用例編寫重寫url。但它不起作用。http重寫不起作用

樣本用戶端URL:

http://frontend1.techdev.local/user1/app/stats/info.png?t=1234

基於請求URI

,它需要將請求重定向到不同後端服務器。

例如,

流1: http://frontend1.techdev.local/user1/app/stats/info.png?t=1234 重定向到 http://app1.techdev.local/user1/app/stats/qwezzsdew.png?t=1234

流程2: http://frontend1.techdev.local/user1/app/html5/qweqwrw.png?t=12345 重定向到 http://app1.techdev.local/newuser/app/html5/qweqwrw.png?t=12345

流程3: http://frontend1.techdev.local/usr1/app/code1/123455.png?t=12345 重定向到 http://app1.techdev.local/newuser/app/code1/qweqwrw.png?t=12345

我開始用第一個測試規則,即使那樣也不行。

RewriteRule "^/user1/app/stats/(.*)$" "http://app1.techdev.local/user1/app/stats/$1 [L]" 

有人可以請這個

+0

您可以啓用併發布重寫模塊的調試日誌([RewriteLog和RewriteLogLevel](https://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog)爲Apache 2.2, [ LogLevel](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging)爲apache 2.4)? –

+0

「不工作」是什麼意思 - 會發生什麼? –

回答

0

嘗試幫助:

RewriteEngine On 
RewriteRule ^user1/app/stats/(.*) http://app1.techdev.local/user1/app/stats/qwezzsdew.png [QSA,L] 
RewriteRule ^user1/app/html5/(.*) http://app1.techdev.local/newuser/app/html5/qweqwrw.png [QSA,L] 
RewriteRule ^usr1/app/code1/(.*) http://app1.techdev.local/newuser/app/code1/qweqwrw.png [QSA,L] 

不知道如果在你的最後一個例子的usr1,就是要user

QSA =查詢字符串追加,所以像?t = 12345這樣的參數將被追加到目標。