使用 apache vhost 配置重定向到新域

Redirect to a new domain using apache vhost configuration

我有一个 apache vhost 配置如下。我想要来自

的所有请求

somedomain.com/loadproduct?product=dell-inspiron-15

将重定向到

其他域。com/dell-inspiron-15

我可以从虚拟主机配置中执行此操作吗?请注意,我在 url.

中有查询参数
Listen 12567
NameVirtualHost *:12567

<VirtualHost *:12567>
    ServerName somedomain.com
    ProxyPreserveHost On

    RewriteEngine On
    RewriteRule ??
</VirtualHost>

非常感谢这里的任何线索。

您可以使用(而不是 RewriteRule ??):

RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]