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!
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.
Hi! Here's a sample. This is namebased virtual hosting. <VirtualHost *:80> ServerAdmin DocumentRoot /home/www/public_html ServerName domain.com </VirtualHost>