Jump to content

Create Subdomain Dynamically Using Php Coding


Recommended Posts

Depending on how you parent domain is defined, you technically do not have "create' anything. Most domains are set up with a wild card as a sub-domain which means you can put anything you want in front.i.e. http://skemcin.w3schools.comSince all the sub-domains, except a few by design (mail, ftp, forums), you can do alot simply with your server side code - again never really creating or defining anything anywhere other than in your php code.

<?Header( "HTTP/1.1 301 Moved Permanently" );Header( "Location: http://subdomain.yourdomain.com/" );?>

Put a condition around that and have the relocation go to a specific folder or skip the redirect and have it set application variables that then drive the rest of the site.I've done both and you can have fun with either one.Of course, you can also manage sub-domain with IIS Mod-Rewrite or (properly) at the DNS level. The IIS re-write must be installed by your hosting provider and managing it at the DNS level will require you to have the ability to create/assign IP addresses for each sub-domain you want.There are several ways to address your situation. If you include a little more details about how and why you need this functionality, it would be easier for other to chime in on which method might be the best approach for you.Let me know if this helps or if you have any other questions or concerns.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...