Redirect to a new domain using apache vhost config

2019-01-29 08:31发布

I have an apache vhost configurations as below. I want all my requests from

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

to be redirected to

someotherdomain.com/dell-inspiron-15.

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.

1条回答
Fickle 薄情
2楼-- · 2019-01-29 08:50

You can use (instead of RewriteRule ??):

RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]
查看更多
登录 后发表回答