Redirect to a new domain using apache vhost configuration

岁酱吖の 提交于 2020-01-11 13:09:32

问题


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:


You can use (instead of RewriteRule ??):

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


来源:https://stackoverflow.com/questions/47475677/redirect-to-a-new-domain-using-apache-vhost-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!