Lengthy story short, I'm trying during the last 3 hrs to do what appears to become a fundamental url redirect. All of the website demands to mysite.com/folder ought to be rerouted to mysite.com/folder/subfolder/. The redirect ought to be carried out "only!" when the user makes its way into /folder. If he accesses /folder/file no redirect should happen.
I've attempted the next but without results, all attempts cause an infinite loop:
RewriteRule ^/folder$ /folder/subfolder/ [R] Redirect 301 /folder /folder/subfolder/
I do not have the vhost file, neither shall we be held permitted to do this using php or perhaps a similar 'workaround'. In either case, htaccess ought to be the best spot to get this done. Can anybody shade an easy on which I'm doing wrong?
redirect make use of a prefix pattern matching, so rather you need to use RedirectMatch having a regex, to ensure that you'll match just the directory access and never the file access within the subdirectory. You don't need the rewriteRule, that is doing exactly the same factor.
This will work:
RedirectMatch ^/folder/$ /folder/subfolder/
Be cautious, you used a 301 Redirect, 301 means permanent, so you may want to close your browser before testing the brand new rule, your browser has commited to memory the redirect permanent answer and won't request it again before you close it.