Subdomains with HTACCESS?

Discussion in 'Apache' started by The Reckoning, Jun 5, 2007.

  1. #1
    Hey everyone.
    I have a server with Apache, it's Linux powered.
    I'm looking to setup an HTACCESS file that will allow the use of subdomains.
    Say I wanted them to be able to visit any subdomain.mywebsite.com, I'd like it to point to the same file, index.php.
    Anyone have any idea how to do this?
     
    The Reckoning, Jun 5, 2007 IP
  2. damonp

    damonp Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In your Apache config just point all subdomains to the same directory.

    With a little PHP you can pull of which subdomain is being hit if that is needed.

    $_SERVER["SERVER_NAME"]
    PHP:
     
    damonp, Jun 6, 2007 IP
  3. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm trying to make it so ANY SUBDOMAIN will point to it. Is there a place in the config file where I can make ANY SUBDOMAIN go to the directory?
     
    The Reckoning, Jun 6, 2007 IP
  4. venetsian

    venetsian Well-Known Member

    Messages:
    1,105
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    168
    #4
    you can do that in the apache config ... I did that for Wordpress MU and it works well ...
     
    venetsian, Jun 6, 2007 IP
  5. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I know it can be done, I'm just trying to figure out how to do it :)
     
    The Reckoning, Jun 6, 2007 IP
  6. venetsian

    venetsian Well-Known Member

    Messages:
    1,105
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    168
    #6
    just set up a wildcard alias *.yourdomain.com in the httpd.conf
    that will do the trick :)
     
    venetsian, Jun 6, 2007 IP
  7. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Is it at all possible with HTACCESS?
     
    The Reckoning, Jun 6, 2007 IP
  8. venetsian

    venetsian Well-Known Member

    Messages:
    1,105
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    168
    #8
    nope -- not possible
     
    venetsian, Jun 6, 2007 IP
  9. The Reckoning

    The Reckoning Peon

    Messages:
    862
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Shame.
    Thanks for the info!
     
    The Reckoning, Jun 6, 2007 IP
  10. venetsian

    venetsian Well-Known Member

    Messages:
    1,105
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    168
    #10
    Yep .. If there was a way I'll be the happiest camper ever ...
     
    venetsian, Jun 6, 2007 IP