问题
What is the best way to create the sub-domain automatically from PHP. I want to develop a application in php in which a user can automatically create a sub-domain from my domain if he/she fills the registration form sucessfully.
回答1:
- Set up wildcard DNS for your subdomains (how you do this depends on your DNS server (or service provider)).
- Configure your HTTP server so that your default virtual host will get everything from the wild carded DNS (how you do this depends on your HTTP server).
- Pay attention to
$_SERVER['HTTP_HOST']
in your script.
来源:https://stackoverflow.com/questions/17595293/how-to-dynamically-create-a-sub-domain-from-a-simple-webpage