Allowing any domain to work on a server...

Discussion in 'Apache' started by The Reckoning, Apr 7, 2008.

  1. #1
    Say I have a standard Apache/PHP/MySQL/cPanel setup on a dedicated server. I can control httpd.conf, shell access, everything.

    I'm trying to allow any domain to work with it. Say I have somewebsite.com and I set the DNS to ns1.myserver.com and ns2.myserver.com (pretend this is my hosting setup,) I want to not have to create an add-on domain, and have it automatically point to public_html/ or some other folder.

    I know this is possible, question is, does anyone here have the code spare? I know it involves editing another file other than httpd.conf.

    Thanks! :)
     
    The Reckoning, Apr 7, 2008 IP
  2. scamp81

    scamp81 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you want to be able to create unlimited subdomains and then have them all point to one spot, you can do this

    Make sure that the site that you will use to do subdomains is the first site in your list of vhosts that is bound to the IP address that you will be using.

    Create * 'A' record in DNS that points to the IP address that you will be using for the site handling the subdomains. This record is a wildcard dns record and will point [anything].yourdomain.com at the IP specified.

    Since the site that you are using to handle requests passed via the wildcard IP address is the first site in your vhost list apache will direct requests for that IP to the appropriate site. If you would like to show different content sites based on the subdomain a user comes in on you can either use code (HTTP_HOST) or use mod_rewrite and a .htaccess file.
     
    scamp81, Apr 8, 2008 IP
  3. ilovelinux

    ilovelinux Peon

    Messages:
    285
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi! Here's a sample. This is namebased virtual hosting.

    <VirtualHost *:80>
    ServerAdmin
    DocumentRoot /home/www/public_html
    ServerName domain.com
    </VirtualHost>
     
    ilovelinux, Apr 8, 2008 IP