The most straigtforward way to redirect traffic for a domain (or subdomain) you longer wish to use to you new, shiny domain (or subdomain) is the following, simple VirtualHost file:
<VirtualHost *:80> ServerName xyz.example.com RedirectPermanent / http://abc.example.com/ </VirtualHost>
All traffic to xyz.example.com
will now be redirected to http://abc.example.com/
. This is also true for whatever query string is added to the domain. E.g. http://xyz.example.com/test
will redirect to http://abc.example.com/test
.
If you have SSL setup, you might want to add the following VirtualHost file using port 443:
<VirtualHost *:443> ServerName xyz.example.com RedirectPermanent / https://abc.example.com/ </VirtualHost>
If you wish to redirect multiple subdomains of the same domain to the same, new domain, simply add a ServerAlias:
<VirtualHost *:80> ServerName xyz.example.com ServerAlias zyx.example.com RedirectPermanent / http://abc.example.com/ </VirtualHost>
0 Comments