The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

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)
 
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)

Like she told your, you have to create a wildcard domain through CPANEL it's quite easy...
Then ask your Web Developer To Create A Router File than can detect subdomain from your current request link...
Then compare it to the allowed domains that you defined through your Interface if it's already registered he executes the process if not the script returns a 404 Error...
=============================
There is another trick that I recommend is WordPress multisite you can do a little research through Google about it you can create multiple WP Sites through the same Cpanel, without duplicating Wordpress files all what you have to do is adding some constants to your wp-config.php file, then you will be able to create subdomains through WordPress panel...
 
  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