How to create subdomains for domains via a php script?

kasutajanimi

Registered
Aug 19, 2015
1
0
1
Estonia
cPanel Access Level
Website Owner
Hey!

What I want to do is to run a php script to which I feed in a list of subdomain names and then it would automatically create those subdomains for a specified domain (and connect those subdomains with folders on my hosting account).
 
Last edited by a moderator:

whatsapprank

Registered
Aug 19, 2015
1
0
1
delhi
cPanel Access Level
Root Administrator
I think you may be talking about a virtual domain in which case you need to create a new DNS entry in the named file as well as a new VirtualHost container in the httpd.conf file.
 

RyanBVI

Member
Sep 4, 2015
8
0
1
BVI
cPanel Access Level
Root Administrator
If you have an MVC php application with managable routes,
maybe you would also find useful the wildcard DNS,
so that ALL subdomains point to a specific php file / router,
so you can programmatically further control the execution ...

(In cPanel, add a subdomain with: * and point it to have document root
to the folder that you have an index.php that serves as your "router"...)