[QCLUG] Multiple Domains - Apache

Cody Wilson belthesar@belthesar.com
Tue, 06 May 2008 14:13:32 -0500


Is there any reason you would be opposed to having the same site appear 
at either http://domaina.com or http://www.domaina.com?  If not, instead 
of using a Rewrite statement, you could just attribute a ServerAlias 
after your ServerName declaration.

IE:

NameVirtualHost *:80

	<VirtualHost  *:80>
	DocumentRoot /var/www/html/domaina/
	ServerName www.domaina.com
	ServerAlias domaina.com
	Options +FollowSymLinks
	</VirtualHost>


Much less pain to set up in the long run.  However, if you're a stickler 
for having sites operate off of www *looks RK's direction* then I'm not 
exactly sure what the issue is.  You might try nestling your Rewrite 
statements in an .htaccess file instead, to see if the file separation 
helps the process.

Thought while I'm doing this... Is there any specific reason you're 
trying to escape your period in the RewriteCond statement?  You 
shouldn't have to.

-Cody Wilson


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/ 
>
>
> _______________________________________________
> QCLUG mailing list
> QCLUG@qclug.org
> http://qclug.org/mailman/listinfo/qclug
>