jluniya — 2011-10-18T05:02:34-04:00 — #1
How can I create sub site like http://a.xyz.com using PHP?
Let's say I have xyz.com and not I want to get a.xyz.com created for user "a". Any way to create this dynamically using PHP?
ralphm — 2011-10-18T05:44:54-04:00 — #2
This is more of a web hosting issue. You need to check with your web hosting control panel. What you want to look for is the facility to create subdomains (the "a" in http://a.xyz.com is a subdomain). This is pretty standard on a lot of hosting accounts, such as those that use CPanel.
logic_earth — 2011-10-18T05:53:21-04:00 — #3
What you actually need is wildcard subdomains. Like, *.example.com would point to the same place as example.com and Apache or IIS would treat it the same. In PHP you would then use $SERVER['HTTPHOST'] to find if the subdomain is a valid username.
However, I must recommend against such practice. While it is nifty, it is a lot of work to get right, and can have security implications.
jluniya — 2011-10-18T06:18:17-04:00 — #4
Thanks a lot for quick response! Both answers address the issue.