Dynamic Subdomains

Discussion in 'Apache' started by Silver89, Jul 18, 2010.

  1. #1
    Quite a few times I've looked into this for guidance on how to do it yet I've never found a sure successful way to complete this, basically I want to be able to access:

    http://domain.com/test.php?username=bob
    Code (markup):
    From:

    http://bob.domain.com
    Code (markup):
    If anyone can help me out with a basic walk through of the steps I need to take that would be brilliant, thanks.
     
    Silver89, Jul 18, 2010 IP
  2. KenJackson

    KenJackson Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you mean you want to redirect?

    My webhost has a CPANEL icon labled Subdomains that allows me to set them up to point to a directory.
    Then you can add a RedirectMath line in .htaccess to specify the exact URL.

    Or do you mean that you want the browser's location bar to say bob.domain.com while the actual content comes from the other URL?

    I would like to see the answer to that too. In fact, I have an active similar question in a different thread.
     
    KenJackson, Jul 24, 2010 IP
  3. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This has been covered quite a bit on DP - try the search, there has been some good answers in the past.
    Look into wildcard catch all subdomains, then you could use .htaccess to send all traffic from them subdomains to a single php script. Like:

    
    RewriteCond %{HTTP_HOST} ^(^.*)\.YourSite.co.uk
    RewriteRule (.*)  processSubdomain.php?username=%1
    
    Code (markup):
     
    Deacalion, Jul 24, 2010 IP