[H-GEN] Multiple Domains - Apache
Sarah Walters
sarah at walters.id.au
Mon Apr 28 20:42:47 EDT 2008
Copying this to list in case others are interested.
Deepan,
Your problem is in where you put the rewrite. See my suggestion below.
On 29/04/2008, Deepan <codeshepherd at gmail.com> wrote:
>
> 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/ .
You can't do this from within the virtualhost stanzas, because
www.domaina.com is a DIFFERENT virtual host from domaina.com. It appears to
be defaulting to the first virtualhost and always hitting that rewrite rule
(which is a bit strange).
What you need to do instead is create virtual hosts for the non-www domain
names and set them to redirect to the www virtualhosts.
Regards,
Sarah Walters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20080429/a31e3669/attachment.html>
More information about the General
mailing list