dynamic creations of subdomains

Discussion in 'PHP' started by shaki, Jul 16, 2007.

  1. #1
    We have our web application developed in .php

    What do you suggest to use with .php so we can create subdomains on the fly, check if desired name of subdomain is available, etc.

    Thank you for any suggestion.
     
    shaki, Jul 16, 2007 IP
  2. glowdot

    glowdot Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could store the subdomains in a database, and point all subdomains to your server's IP in your zone record. Then examine the subdomain on request and redirect to the correct page. You could also use a rewrite rule for this part.
     
    glowdot, Jul 16, 2007 IP
  3. SIR

    SIR Member

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    actually it's done in htaccess not php...
     
    SIR, Jul 16, 2007 IP
  4. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If your DNS entry states *.yourdomain.com then you can have as many sub domains as you like and they'll all get routed to your server.

    Then use $_SERVER['host'] to extract the subdomain they are using within PHP or do a modrewrite in htaccess if you want to change it to the form of ?subdomain=<subdomain>.

    I run 170 subdomains on my site using this method and it works great. I then look up the content for that subdomain in the database et viola!
     
    ecentricNick, Jul 17, 2007 IP