dynamice subdomain creation

Discussion in 'PHP' started by isnain, Jan 7, 2008.

  1. #1
    Is there any way to create subdomain dynamically. All i want to do is to give each of my user a url like :
    www.username.sitename.com
    it as soon as user gets him/herself registered is there any way to do it , can anybody help me. Thanks in advance.
     
    isnain, Jan 7, 2008 IP
  2. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #2
    srobona, Jan 7, 2008 IP
  3. isnain

    isnain Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks srobona url rewrite worked for me
     
    isnain, Jan 8, 2008 IP
  4. craze3

    craze3 Well-Known Member

    Messages:
    454
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #4
    This is what I found to use.. and I'm posting it for anyone else who might need this snippet in the future:
    RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
    RewriteCond %{REQUEST_URI} !^/userdir/ [NC]
    RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
    RewriteRule ^.*$ /userdir/index.php?user=%1 [L]
    Code (markup):
    Should go from http://user1.domain.com to http://domain.com/userdir/index.php?user=user1 :)
     
    craze3, Jan 8, 2008 IP
  5. akram

    akram Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Don't forget to enable wild-card sub-domains. If you are on a shared hosting, ask your server admin to enable it.

    The URL rewriting above will not work without it.
     
    akram, Jan 9, 2008 IP