apacheThere are several cases when you would like to use dynamic subdomains. In case your webhosting don’t support unlimited subdomains or when you’re developing a community website with a focus on the user profiles. In this case I recommend you to write a script which allows users to create personal pages with a clear address like ‘crispijn.yourdomain.com’.

Obviously do I know the .htaccess solution to create subdomains. This is very handy if you don’t have cPanel or another web admin tool.

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/%1 [L,R]

This solution points to a folder in your root so it isn’t a very dynamic one. Lets see the solution!

Continue Reading »

Top of Page