Creating name.domain.com on the fly

Discussion in 'PHP' started by keiths, Jun 4, 2007.

  1. #1
    So what is involved with creating DNS entries on the fly via PHP. So if a user registers on the site with the username of dp. The DNS entry dp.domain.com is automatically created? Or is there some sort of trickery to make this work?
     
    keiths, Jun 4, 2007 IP
  2. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #2
    The way to do this is to add a @ to your DNS A record that points to the IP of your site. This way anything thats requested followed by .domain.com resolves to your sites IP.

    Then, you need to make sure your HTTPD, apache or whatever you use, is set so that it accepts ANYTHING.domain.com as a request for your web site.

    At this point, *.domain.com opens your site, from here you can check which host was requested exactly via $_SERVER["HTTP_HOST"] if you want to do some work based on that.

    I hope that makes sense :)
     
    mrmonster, Jun 4, 2007 IP
  3. keiths

    keiths Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Awesome, thanks
     
    keiths, Jun 4, 2007 IP