Posts tagged htaccess
Dynamic username as subdomain system with .htaccess
Feb 8th
Create an .htaccess file with the following code to build a dynamic username as subdomain.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?username=%1 [L]
All visits to http://username.mydomain.com will redirect to index.php?username=subdomain. You can then assign that username to a cookie and build the user’s web page.
Remember to edit your bind configuration and add the following:
* IN A IP_ADDRESS
Restart named and test your new dynamic subdomain system.
Follow me on Twitter