How To Rewrite Subdomains Unto Main Files?

Discussion in 'Site & Server Administration' started by MBDungo, Jan 23, 2013.

  1. #1
    Guys, I'm planning to build a website that able to register users which their usernames will become their own subdomains.

    Would you please help me to rewrite the specific subdomains of http://firm.tk to the query string of firm.tk/sites.php?domain=

    For example, firm.tk/sites.php?domain=test and firm.tk/sites.php?domain=user and firm.tk/sites.php?domain=name are all exist, all of test.firm.tk and user.firm.tk and name.firm.tk will automatically rewrite those files that in query string.

    And tell me what's the requirements to do that, such as do a free web hosting have a capacity to do it? Or any sure tips related to this topic?
     
    MBDungo, Jan 23, 2013 IP
  2. Snat

    Snat Well-Known Member

    Messages:
    86
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    130
    #2
    The first thing you will need is to find a web host that allows you to use wild card subdomains and point them to the same directory. I have rarely found a free web host that does this so your best bet would simply to rent out a VPS and setup Apache or whichever web server you wish to use yourself.

    From there you will need to write a bit of .htaccess. Sadly I am not the best at .htaccess and unable to help without trying it myself first. That said search on Stack Overflow as someone has likely posted examples before.
     
    Snat, Jan 23, 2013 IP
  3. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks for responding! But, I still wonder if subdomains can rewrite to those kinds of main query strings even without the use of wild card DNS. And I want to try to write an .htaccess first before finding a free host that supports a wild card if it's posible.
     
    MBDungo, Jan 23, 2013 IP