Redirecting client to single domain name.

Here is a problem where a site is hosted under different virtual hosts with different domain names.

Example:
VirtualHost1 is setup for http://www.example.net
VirtualHost2 is setup for http://www.example.com

And, we want to redirect to or show only http://www.example.com domain to our clients.

Then, make some changes as below in main apache config file that is httpd.conf:

 <VirtualHost *:80>
  ServerName www.example.net
  ServerAlias example.com
  Redirect permanent / http://www.example.com/
 </VirtualHost>
<VirtualHost *:80>
 ServerName www.example.com
 DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

Leave a Reply