2016-10-05 49 views
0

目前,我有一个重写规则如下。重写规则重定向到另一个端口,同时更改目录

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^_escaped_fragment_= [NC] 
RewriteRule^http://localhost:8082%{REQUEST_URI} [L,P] 

在该重写规则,如果我发送具有_escaped_fragment_=像下面的URL,

http://localhost:8080/web/?_escaped_fragment_=/privacy 

的URL被重定向到不同的端口(8080至8082),如下,

http://localhost:8082/web/?_escaped_fragment_= 

我现在想要做的是修改这个重写规则,从URL中删除/web,并重定向到一个新的端口(8080到8082),如果URL有_escaped_fragment_=它。举个例子,如果我的网址如下,

http://localhost:8080/web/?_escaped_fragment_=/privacy 

我想这个URL重写像下面URL(新网址具有端口8082和/web是在新的网址不存在),

http://localhost:8082/?_escaped_fragment_=/privacy 

这是什么重写规则?

回答

0

除了使用%{REQUEST_URI}变量,你需要符合实际的URL:

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^_escaped_fragment_= [NC] 
RewriteRule ^/?(?:web/)?(.+)$ http://localhost:8082/$1?%{QUERY_STRING} [L,P] 
相关问题