SitePoint Sponsor

User Tag List

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

    Create sub domains

    Hi All,

    Wondered if anyone could help or point me in the right direction.

    I am building a site that users can sign up to and it creates a subdomain and pages and photos under there own sub domain.

    Currently I don't think what I have done is the best way of doing it. Currently when you create a user I have written that it basically creates the subdomain and copies the whole website to the new subdomain, not the best for space, what I want to know is how I can get it to create a virtual subdomain and that when people type in the address eg subdomain.site.com it pulls up the data from a database and puts the info into a template to be displayed

    I have a basic understanding of databases it's the subdomain bit I need help with

    Hope this makes sense

    Thanks



    Sent from my iPhone using Tapatalk

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    That depends on which webserver you're using, and then there are multiple ways of handling it.

    One way would be to configure the webserver to pass all traffic on the subdomains (*.yourdomain.com) to your PHP script, and then you use the subdomain name to figure out which site to display.

    Pseudo code:
    PHP Code:
    $host $_SERVER['SERVER_NAME'];
    $host explode('.'$host);
    $sub $host[0]; // e.g. mysub.yoursite.com would give $sub = mysub 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool I use hostgator so will give it a go, thanks for your help


    Sent from my iPhone using Tapatalk

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You'll have to check out hostgator's control panel to see what options they have for wildcarding subdomains. Perhaps their support can tell you more. Good luck


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
  •