Multiple subdomains to same address

104 views Asked by At

I want to redirect multiple subdomain to same address. Let's say I want www.sitename.com and sitename.com to redirect same address.

Do I have to say;

<VirtualHost www.sitename.com:81>
    .
    .
    .
</VirtualHost>

<VirtualHost sitename.com:81>
    .
    .
    .
</VirtualHost>

or is there a simple solution.

1

There are 1 answers

0
Panama Jack On BEST ANSWER

Yes, If you wish to use multiple addresses like subdomains to the same location you can do this.

<VirtualHost *:81>
     ServerName example.com
     ServerAlias www.example.com sub1.example.com sub2.example.com
     DocumentRoot /var/www/example.com
     #more stuff etc here if needed    
</VirtualHost>

It's part of name based virtual host.

http://httpd.apache.org/docs/2.2/vhosts/name-based.html