2016-11-26 128 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这样的参数将被追加到目标。