[lug] Multiple Domains - Apache

Walter Pienciak wpiencia at thunderdome.ieee.org
Mon Apr 28 18:26:07 MDT 2008


On Tue, Apr 29, 2008 at 05:07:27AM +0530, Deepan 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>
> 
> However all requests to http://domainb.com/ gets
> redirected to http://www.domaina.com  whereas the
> expected behaviour is to get redirected to
> http://www.domainb.com/ . 
> Regards 
> Deepan 

Hi, Deepan,

I don't see another reply yet, and am pressed for time today, but
my general suggestion for debugging rewrite issues is to turn
debugging WAY UP while you do it.

You may also want to set your ServerAlias(es) to the hostnames
domaina.com and domainb.com respectively.

Walter



More information about the LUG mailing list