The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “CPA

How to create sub-domains using PHP ?

Your sub-domains exist on your server space. You set them up based on how many you can have with your hosting plan ... your question is not clear what you are trying to do and where the php code would come in ... can you spell that out a bit more?
 
To create sub-domains, you need to work on cpanel
PHP can not create sub-domains
 
If you are managing your server yourself (eg: Ubuntu), then you're probably running Apache2 webserver -- in those configuration files you'll need to create subdomains. And u'll also have to add the appropriate DNS record(s).

However, as others pointed out above, you are most likely using a managed hosting (such as CPanel) which allows you to create/add subdomains.
 
For creating a sub-domain, you should work on Cpanel, in Cpanel, we should a write a PHP code dynamically which is used to create a sub -domain.
And if you are working on Ubuntu then you navigate to your sites-available directory and create the necessary file for Apache.
 
For creating a sub-domain, you should work on Cpanel, in Cpanel, we should a write a PHP code dynamically which is used to create a sub -domain.

  • Create an A record at DO for a wild-card sub-domain (*.users.your-domain.com, for example)
  • In apache, create a wild-card vhost:
Example vhost config (written for CentOS 6.6)
 
Nothing to say here - Nothing to say here - Nothing to say here
Nothing to say here - Nothing to say here - Nothing to say here
Nothing to say here - Nothing to say here - Nothing to say here
Please Remove My Account
 
Last edited by a moderator:
  1. Do a wildcard A entry in your nameserver for that domain. Sub domains are a DNS function;
    Code:
    * example.com A 123.321.99.33
  2. write a file (PHP include) to map the sub-domains to the right data, files or to the correct mapped sub directory,
  3. in the webserver (Apache, Nginx) document root create an index.php,
  4. do the code work there.
 
banners
Back