[GLLUG] Multiple Domains - Apache
Thomas Driscoll
tad001 at sunn.net
Fri May 9 07:37:13 EDT 2008
I assume you are hosting both of the sites locally?
When I want 2 URLs to go to the same directory I usually use the
ServerAlias commands in the Apache httpd.conf (or virutualhost included
file). So along with ServerName try just one VirtualHost container and
add the www.domainb.com as a ServerAlias.
<VirtualHost 69.41.4.8>
ServerAdmin webmaster at domainb.com
DocumentRoot /web/website directory
ServerName www.domainb.com
ServerAlias www.domainb.com
ErrorLog /web/logs/website directory/error.log
CustomLog /web/logs/website directory/access.log combined
<Directory "/web/website directory">
Options Indexes FollowSymLinks
AllowOverride None
AddOutputFilterByType DEFLATE text/html
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This example is from a site I have been using for years. Usually I am
just capturing the www.domain.com and domain.com but your example should
function very well also.
On Tue, Apr 29, 2008 at 05:05:05AM +0530, 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/
>
>
> _______________________________________________
> linux-user mailing list
> linux-user at egr.msu.edu
> http://mailman.egr.msu.edu/mailman/listinfo/linux-user
--
Thomas Driscoll
e-mail: tad001 at sunn.net
phone:(517)944-2041
Death is nothing to us, since when we are, death has not come, and when death has come, we are not.
by: Epicurus
More information about the linux-user
mailing list