1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess and subdomains

Discussion in 'Apache' started by General Grant, May 14, 2005.

  1. #1
    I have a script which allows my members to create a free website, like geocities. As it is now, they get the url www.mysite.com/user, and would like to know if it is possible to use the .htaccess file to direct to user.mysite.com, without actually having to create the subdomain.

    Hope this makes sense.
    SEMrush
     
    General Grant, May 14, 2005 IP
    SEMrush
  2. lorien1973

    lorien1973 Notable Member

    Messages:
    12,206
    Likes Received:
    601
    Best Answers:
    0
    Trophy Points:
    260
    #2
    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /

    RewriteCond %{HTTP_HOST} sub.yoursite.com
    RewriteCond %{REQUEST_URI} !subfolder/
    RewriteRule ^(.*)$ subfolder/$1 [L]

    set your sub and your subfolder. This should work.
     
    lorien1973, May 14, 2005 IP
  3. General Grant

    General Grant Well-Known Member

    Messages:
    318
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    160
    #3
    I tried it, and it didn't work. Even if it did, that way I would have to manually add it with each new membership signup. I'm looking for a way that with each new signup, it would automatically work. Thanks for your help anyways.
     
    General Grant, May 14, 2005 IP
  4. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #4
    Along with the folder that needs to be setup,sd
    you also need to setup wildcard dns; if it isn't already. The users zone file would look something like:

    * 14400 A 123.123.123.123

    This is the htaccess I"ve always used:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    Rewrite Rule for jane.domainname.com
    RewriteCond %{HTTP_HOST} jane.domainname.com$
    RewriteCond %{REQUEST_URI} !jane/
    RewriteRule ^(.*)$ jane/$1

    If you have control of the server; then you could write a script that does all three at signup.
     
    flawebworks, May 14, 2005 IP
  5. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #5
    One other thing you need to do is to set up your dns entries for the subdomain. Jane.domainname.com isn't going to work unless it resolves to an address. Once the DNS solution is in place the rewrite rules should work.
     
    nevetS, May 14, 2005 IP
  6. honey

    honey Prominent Member

    Messages:
    15,555
    Likes Received:
    712
    Best Answers:
    0
    Trophy Points:
    325
    #6
    if changing the script is not a oroblem, try hotscripts, there are a couple scripts that help u do this. u would still need to do the one time wildcard dns entry explained above.
     
    honey, May 14, 2005 IP
  7. General Grant

    General Grant Well-Known Member

    Messages:
    318
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    160
    #7
    That was the problem, my server doesn't allow wildcards, whatever the hell that means LOL.

    Thanks anyways.
     
    General Grant, May 14, 2005 IP
  8. kusadasi-guy

    kusadasi-guy Peon

    Messages:
    83
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    What a coincidence!
    Today i was working on this subject and just uploaded the script to my friend's server, "url2subdomain" ;

    http://www.gitme.net/php/
     
    kusadasi-guy, May 14, 2005 IP