[CALUG] Multiple Domains - Apache

Brandon Checketts brandon at brandonchecketts.com
Mon Apr 28 20:14:09 EDT 2008


You need a ServerAlias for 'domainb.com' inside the second VirtualHost (also a 
ServerAlias for 'domaina.com' inside the first one).  As it is now, your client 
is sending an HTTP_HOST header of 'domainb.com' which doesn't match any of the 
defined virtual hosts.  When Apache receives a request for a host that doesn't 
exist, it uses the first defined one.

It's a bit strange that the redirect is working, since your RewriteCond is 
requiring that specific HTTP_HOST header.   Perhaps your application is doing 
the redirect instead of the web server?

Thanks,
Brandon Checketts


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 
> 
> Photographic Memory Game:
> http://www.photographicmemorygame.com/
> Sudoku Solver: http://www.sudoku-solver.net/ 
> 
> 
> 
> _______________________________________________
> CALUG mailing list
> CALUG at unknownlamer.org
> http://lists.unknownlamer.org/listinfo/calug





More information about the CALUG mailing list