Wednesday, January 26, 2011

All subdomains routed to same DocumentRoot, apache config

You've seen it done on sites like basecamphq.com where you would have username.basecamphq.com

I'm wanting to do a similar thing, any subdomain is routed through to the same index.php file.

so username1.example.com will request /home/some/path/to/www (in here is index.php) and username2.example.com will request the same file

I have it working locally, but my server uses cPanel. What would be your guess at the apache conifguration?

  • <VirtualHost *:80>
        DocumentRoot  /home/some/path/to/www 
        ServerName www.example.com
        ServerAlias *.example.com
    </VirtualHost>
    

    Something like that, perhaps?

    James Lawrie : worth noting that you'll also need wildcard DNS

0 comments:

Post a Comment