2017-04-06 20 views

回答

0

您可以使用此:

RewriteEngine on 

#redirect /?querystring to http://y.com/?querystring 
RewriteCond %{QUERY_STRING} .+ 
RewriteRule ^$ http://y.com/ [L,R] 
#/anyUri to http://y.com/anyUri but exclude the root 
RewriteRule ^.+ http://y.com%{REQUEST_URI} [L,R] 
+0

谢谢你,我针对任何QUERY_STRING和REQUEST_URI –

+0

我已经更新了代码,按您的评论。 – starkeen

+1

大,这是有帮助的。谢谢 只是小幅调整需要{REQUEST_URI] >> {REQUEST_URI} –

0

QUERY_STRINGREQUEST_URI参数的一部分。你只需要检查后者的存在:

RewriteEngine On 

RewriteCond %{REQUEST_URI} ^/. 
RewriteCond %{HTTP_HOST} ^(?:www\.)?x\.com$ 
RewriteRule^http://y.com%{REQUEST_URI} [R,L,QSA] 
+0

谢谢 我相信你的意思是不是HTTP_HOST HTT_HOST 它与 http://X.com/images >> http://Y.com/images 但与 http://X.com/?action=show >> http://Y.com/?action=show 但它适用于 http://X.com/index.php?action=show >> http://Y.com/index.php?action=show –

+0

@ZhahairAli是的。错字固定。还添加了QSA标志,以便单个规则可以处理所有情况。 – hjpotter92

相关问题