Setting up a Wildcard or Catch-all Subdomain
The set-up is pretty easy, just a simple modification of the DNS to include a record with the name:
*.domain.ca
Then add the same thing to your ServerAlias line in the Apache configuration. (You probably won?t have permission to perform the two previous steps if you?re on shared hosting, so ask your web host to do it for you). Finally, create a mod_rewrite that will read the subdomain as a parameter on another page, e.g.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^
www.domain.ca
RewriteRule ^(.*) http://www.domain.ca/?p=$1 [L,R=301]