It has been a while since I’ve been thinking over this feature that some websites are implementing and it looks to be very successful.
Websites like tumblr.com, blogger.com, wordpress.com allow users to register new sub-domain names from within the website by using a simple HTML/PHP form. With my current knowledge of PHP I couldn’t figure out myself how this is done. I’ve read some posts on this and still can’t build a clear idea about this.
So, how do I create a script that allows users to register their own sub-domains on my website (www.username.mydomain.com) and more than that, how do I allow them to use a different website template (as wordpress.com does). Is this possible to be done on a shared server or a dedicated server is needed?
These subdomain issues are brought down to the level of nice URLs, friendly URLs etcetera, as this feature has various names.
Basically what you do is that you set up a redirection so that if someone enters
foobar.example.org, the server will serveexample.org/user.php?name=foobarorexample.org/foobar. After this, it’s only a matter of how you put together your PHP script so thatuser.phpor the contents of/foobaris parsed properly. The “registration” part is statically done in the.htaccessfile in your DocumentRoot.Of course this will need some sort of proper error handling for a nonexistant “subdomain”.