SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to create sub site?

    Hi,

    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?

    Thanks.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,599
    Mentioned
    411 Post(s)
    Tagged
    7 Thread(s)
    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.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    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['HTTP_HOST'] 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.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for quick response! Both answers address the issue.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •