[QCLUG] Multiple Domains - Apache
Roadkill the Avatar of Misfortune
roadkill-ml@darktraveler.com
Sun, 11 May 2008 17:40:32 -0500
I'd say the biggest reason your having trouble here is that those rewrites
need to be in the domainb.com virtual host stanza, instead of in the
www.domainb.com stanza..
If those are the only two stanza's in your domain, but dns points to the ip of
your server, the apache server will not know which server is being asked for,
and so it will use the default (usually the first domain in it's virtual host
table)
The way I deal with these types of situations is as follows:
<VirtualHost 10.101.10.13:80>
ServerName www.domaina.com
Important site stuff here
</VirtualHost>
<VirtualHost 10.101.10.13:80>
ServerName domaina.com
Redirect 303 / http://www.domaina.com/
</VirtualHost>
Rewrites work for some tasks, but a redirect should be a little faster and
simpler to debug in the case your suggesting.
Hope that helps,
rk
On Monday 28 April 2008 18:37, 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