Rewrite rule to redirect direct access subdirectory to subdomain

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(.*)$$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,

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.