Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Multiple Domains - Apache





On Tue, Apr 29, 2008 at 8:34 AM, Deepan <codeshepherd@example.com> wrote:
Hi All,
       I am serving two domains from the same machine
using Apache. I want www to be used in both of the
domains, hence I redirect  urls without www to
appropriate urls with www. I have the following
configuration in httpd.conf to achieve this.



       NameVirtualHost *:80

       <VirtualHost  *:80>
       DocumentRoot /var/www/html/domaina/
       ServerName www.domaina.com
       Options +FollowSymLinks
       RewriteEngine On
       RewriteCond %{HTTP_HOST} ^domaina\.com$ [NC]
       RewriteRule ^(.*)$ http://www.domaina.com$1
[R=301,L]
       </VirtualHost>


       <VirtualHost *:80>
       DocumentRoot /var/www/html/domainb/
       ServerName  www.domainb.com
       Options +FollowSymLinks
       RewriteEngine On
       RewriteCond %{HTTP_HOST} ^domainb\.com$ [NC]
       RewriteRule ^(.*)$ http://www.domainb.com$1
[R=301,L]
       </VirtualHost>




Make sure that for every www.domainx.com you create a ServerAlias to domainx.com.

In fact, in practice, domainx.com should be the servername, and www.domainx.com should be the alias.

For instance, right after the line
ServerName www.domaina.com
ServerAlias domaina.com

But as I said, I would reverse the positions.  www should be an alias, as it is more specific.






Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links