使用apache vhost配置重定向到新域
问题描述:
我有一个如下的apache虚拟主机配置.我希望所有来自
I have an apache vhost configurations as below. I want all my requests from
somedomain.com/loadproduct?product=dell-inspiron-15
要重定向到
someotherdomain.com/dell-inspiron-15 .
我可以从vhost配置中执行此操作吗?请注意,我在网址中有查询参数.
Can I do this from vhost configuration? Note that I have query parameters in the url.
Listen 12567
NameVirtualHost *:12567
<VirtualHost *:12567>
ServerName somedomain.com
ProxyPreserveHost On
RewriteEngine On
RewriteRule ??
</VirtualHost>
这里的任何潜在顾客都非常感激.
Any leads here is really appreciated.
答
您可以使用(代替RewriteRule ??
):
RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]