Reputation: 24768
I have the following working rule in my htaccess file:
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
However this prevents my admin panel to work. Is it possible to exclude a directory and its subfolders from this rule?
Exclude folders like this (exclude panel
folder):
/panel/
/panel/a-subfolder/
/panel/a-subfolder/deeper/
They should work without the rule, without the ending slash as well like /panel/a-subfolder
Don't exclude folders like this:
/another-unknown-folder/
/some-other-folder/folder/folder2/
They should follow the rule, force slash as the rule does today.
Upvotes: 1
Views: 77
Reputation: 785128
You can add an additional RewriteCond
for exclusion:
RewriteCond %{REQUEST_URI} !^/panel/
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
Upvotes: 1