[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Multiple domains to a single site.



Owen Lees wrote:

> The way I see it is that as a lot of folks (such as ourselves) have one IP
> which is set to a standard site for the box.  When a client comes along and
> wants to have multiple domains the only option that so far I have been able
> to do is to make up loads of virtual sites with a redirect page on each one
> (ie: index.html contains a re-direct header)

There's a much easier way, if all you want to do is redirect the site. 
Take a look at the virtual host block inserted by my RaQ2 gui when I
added the site "freeparking.nobaloney.net".

  NameVirtualHost 209.126.157.79
  <VirtualHost 209.126.157.79>
  ServerName freeparking.nobaloney.net
  ServerAdmin admin
  DocumentRoot /home/sites/site14/web
  RewriteEngine on
  RewriteCond %{HTTP_HOST}                !^209.126.157.79(:80)?$
  RewriteCond %{HTTP_HOST}               
!^freeparking.nobaloney.net(:80)?$
  RewriteRule ^/(.*)                     
http://freeparking.nobaloney.net/$1 [L,R]
  RewriteOptions inherit
  AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site14/users/$1/web/$3
  AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site14/users/$1/web/$3
  </VirtualHost>

Now, let's presume we get a customer, whose domain name is "newsite.com"
that he'd like us to "free-park" for him until such time as he uses it.

Here's what we do:

First, we add a DNS zone file for him.  It should have two A records in
it:  One for "newsite.com" and one for "www.newsite.com".  They should
both point to the IP# you use for virtual hosting on your system.

Second, to the virtual host block shown above, add the follwoing two
lines directly under the ServerName line:

  ServerAlias www.newsite.com
  ServerAlias newsite.com

Be sure to restart both your named daemon and your httpd daemon.

Now whenever anyone uses their browser for either "www.newsite.com" or
for "newsite.com", it'll find the site at "freeparking.nobaloney.net"
(in my example, anyway).

One problem is that the location bar will change to say
"http://freeparking.nobaloney.net";.

That could be a problem, the user could no longer tell which site s/he'd
typed into the location bar.

To solve that problem, look for the lines that say:

  RewriteEngine on
  RewriteCond %{HTTP_HOST}                !^209.126.157.79(:80)?$
  RewriteCond %{HTTP_HOST}               
!^freeparking.nobaloney.net(:80)?$
  RewriteRule ^/(.*)                     
http://freeparking.nobaloney.net/$1 [L,R]
  RewriteOptions inherit

And put a comment mark in front of them.  Now they should say:

  #RewriteEngine on
  #RewriteCond %{HTTP_HOST}                !^209.126.157.79(:80)?$
  #RewriteCond %{HTTP_HOST}               
!^freeparking.nobaloney.net(:80)?$
  #RewriteRule ^/(.*)                     
http://freeparking.nobaloney.net/$1 [L,R]
  #RewriteOptions inherit

The disadvantage here is that calls to http://newsite.com/siteadmin and
to http://newsite.com/useradmin will no longer work for this site. 
Frankly, for me that doesn't matter; I don't want my clients messing
with administration functions.

If it matters for you and your customers then you can't comment out the
rewrite rules; it's that simple.

For those of you who have trouble following the above, here's what the
virtual domain block should look like after I'm done:

  NameVirtualHost 209.126.157.79
  <VirtualHost 209.126.157.79>
  ServerName freeparking.nobaloney.net
  ServerAlias www.newsite.com
  ServerAlias newsite.com
  ServerAdmin admin
  DocumentRoot /home/sites/site14/web
  #RewriteEngine on
  #RewriteCond %{HTTP_HOST}                !^209.126.157.79(:80)?$
  #RewriteCond %{HTTP_HOST}               
!^freeparking.nobaloney.net(:80)?$
  #RewriteRule ^/(.*)                     
http://freeparking.nobaloney.net/$1 [L,R]
  #RewriteOptions inherit
  AliasMatch ^/~([^/]+)(/(.*))? /home/sites/site14/users/$1/web/$3
  AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/site14/users/$1/web/$3
  </VirtualHost>

That's it.

Of course mail is another story all together <smile>.  Let me know if
you need mail forwarded as well.

> As I understand this, the only way to ensure redirection is if all the
> domains are sitting on one machine and thats all that machine is used for..

Your understanding is quite faulty.

> this is impossible to justify costs wise for a small company such as
> ourselves.
> Otherwise I have seen (probably correct) suggestions on implementing another
> IP number on the RAQ2, I have since gotten another IP and still cant get the
> DNS to operate correctly, if I create an A record and point to the new IP it
> comes up with the site on the original IP! (Thats even when the site to
> which I wish to send redirects is sitting on the new IP happily and takes
> requests for that IP directly from the browser URL line).

Since there are reasons why this could happen I'd have to look at your
specific system configuration to know why this is happening.

In order for me to do that you have to retain me; I don't look into
systems gratis; the liability is just too great.

> So there we go... stuck really!

No, you just have to learn how to do it.

> I still need to be able to do redirection of domains to other domains whilst
> the machine is not dedicated to the original domain.

Fine.  I just showed you how.  If it doesn't work, the issue is NOT in
apache, but possibly in DNS.

Jeff
-- 
Jeff Lasman <jblists@xxxxxxxxxxxxx>
nobaloney.net
P. O. Box 52672
Riverside, CA  92517
voice: (909) 787-8589  *  fax: (909) 782-0205