[Ryedale] Multiple Domains - Apache

Martin Wheldon mwheldon at googlemail.com
Tue Apr 29 08:34:39 BST 2008


Hi Deepan,

Have you tried somthing like this

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^www\.domaina\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.domaina.com/$1 [L,R]

Shamelessly grabbed from here.

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Hope this helps

Martin



On 4/29/08, Deepan <codeshepherd at gmail.com> 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/
>
>
>
>



More information about the Ryedale mailing list