I'm using the following RewriteRule to redirect wildcard sub domains to the corresponding folders in the /users sub-direcotry:
RewriteCond %{REQUEST_URI} !^/users/ [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteCond %1 !=www [NC]
RewriteRule ^(.*)$ /users/%1/$1/? [L]
I would like to prevent direct access to the users' folder by 301 redirecting to the sub domain version like this:
www.domain.com/users/username/sub1/sub2/ => username.domain.com/sub1/sub2/
Any help would be greatly appreciated!