Dean Putney
Dean Putney

Reputation: 745

Creating subdomains dynamically for an application

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!

Upvotes: 0

Views: 1443

Answers (2)

Colin O'Dell
Colin O'Dell

Reputation: 8647

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.

Upvotes: 0

Amber
Amber

Reputation: 526483

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.

Upvotes: 5

Related Questions