views:

360

answers:

3

I want to create subdomains dynamically through a PHP script or something similar. I've seen lots of sites that create subdomains for individual users, or for new forum spaces. I'm just wondering how that works, and how I can implement it in my system.

Thanks for your help!

+5  A: 

Take a look into wildcard subdomains. Once you have all of the "subdomains" going to the right place, you can use url rewriting and/or some other mixture of redirecting to create the effect of subdomains without having to constantly update a httpd.conf setup and/or DNS tables.

Amber
A: 

If you are using Apache on a Linux box, you can create new VirtualHosts for each subdomain. Here is a guide for Debian/Ubuntu which may also work for other distros.

Basically: each entry goes into its own file under /etc/apache2/sites-enabled. Whenever an entry is added/changed/removed, you run 'sudo /etc/init.d/apache2 reload' to update the virtual hosts / subdomains.

Colin O'Dell
A: 

see this - http://ma.tt/2003/10/wildcard-dns-and-sub-domains/

Arpit Tambi