I have found and added the following snippet to my .htaccess file to redirect direct access of a subdirectory to its subdomain:
RewriteCond %{REQUEST_URI} ^/folder
RewriteRule ^folder(.*)$ http://folder.example.com$1 [R=301,L]
This works fine, but I have also subdirectories in ‘/folder’ and these subdirectories might have there own subdirectories too, etc. Is there some regular expression that I can add to the snippet, so that it also redirects direct access to its subdirectories? Or perhaps even better… also redirects direct access to files in ‘/folder’ and its subdirectories? The latter would be great, but if not only the subdirectories would be fine.
Cheers & thanks for your time,
Ralph