[sllug-members]: Multiple Domains - Apache

Matt Warnock mwarnock at ridgecrestherbals.com
Mon Apr 28 17:55:10 MDT 2008


Could be wrong, but here's what I think is happening.  First virtualhost
is www.domaina.com, so any access under www.domaina.com gets that one.
Second virtualhost is same but domainb, so far so good.  When any
hostname comes in that doesn't match either one, it gets served by the
first (default) virtualhost.  Hence the problem.

I think you need a domainalias statement.  My hosts all begin with: 
servername www.example.com
serveralias example.com *.example.com

That way the www is the canonical address for apache, but any request to
a host under that domain name, or no hostname at all, just the bare
domain name (provided DNS routes it there) will be served by that
virtualhost.

-  
Matt Warnock, President
RidgeCrest Herbals, Inc.


On Mon, 2008-04-28 at 17:58 -0600, Adam Barrett wrote:
> I think this might be something I have seen before (read as: I've done this one)
> 
> in your VirtualHost directives drop the :80
> 
> This you have already declared your port in the NameVirutalHost Directive.
> 
> I am unsure of all the ReWrite stuff... seems excessive to me, I could
> be crazy though..
> 
> Good luck.
> 
> On Mon, Apr 28, 2008 at 5:39 PM, 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/
> >
> >
> >  ______________________________________________________________________
> >  See http://www.sllug.org/ for latest SLLUG news, information, links.
> >  Join SLLUG and other UT LUG members on irc.FreeNode.net channel #Utah
> >  sllug-members at sllug.org
> >  http://www.sllug.org/cgi-bin/mailman/listinfo/sllug-members
> >
> 
> 
> 



More information about the sllug-members mailing list