2 domain names -> 1 server -> 2 different websites

Discussion in 'Windows Desktop Systems' started by Glaanieboy, Feb 12, 2004.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I am curious. I am using Apache 2 on a Windows XP Pro machine. Currently, I have a dyndns.org account, that redirects glaanieboy.dyndns.org to my home machine. What I want to know, is it possible to create another dyndns account (or any other redirecting service, such as freeddns) and have that domain redirect to the same server, but to another directory? Is this what Virtual Host stands for?
    I hope I make sense here, if not, please say so.
     
  2. blinden

    blinden OSNN Senior Addict

    Messages:
    268
    Location:
    Pittsburgh, Pa, USA
    I know this is, for me, easier to do under IIS because you can just give one NIC mulitiple IP addresses and then point different domains in to different "IP's" however, this wouldn't work in your situation because I would figure you recieve your IP dynamically from your ISP (Which would explain the DYNDNS stuff you need). Sorry I cannot help you with this, I don't think it's possible because of your internet service.
     
  3. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Thanks blinden, though I am sure I have seen it somewhere. Somehow Apache must detect from which domain the server was accessed and provide the correct website. Am I right?
     
  4. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    This is what I use on my apache server for name based virtual hosting

    NameVirtualHost *

    <VirtualHost *>
    ServerAdmin admin@domain.com
    DocumentRoot /path/to/html/documents/
    ServerName second.domain.com
    ServerAlias second
    <Directory "/path/to/html/documents">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>
     
  6. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Thanks, that was the solution :)
     
  7. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Hmm, didn't work quite like I wanted. As I said, I already had glaanieboy.dyndns.org redirected to my server, but when I added the other dyndns.org account I created as a VH, both domain names would redirect to the second website. So I added both sites as a VH:
    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName second.dyndns.org
    ServerAlias second
    DocumentRoot "C:/path/to/second/site"
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName first.dyndns.org
    DocumentRoot "C:/path/to/first/site"
    </VirtualHost>
    
    And that worked :)
     
  8. blinden

    blinden OSNN Senior Addict

    Messages:
    268
    Location:
    Pittsburgh, Pa, USA
    interesting... and excellent...