I am forcing trailing slashes on my website but it's caused an issue with our Wiki, as it treats them as a blank page.
Want I want to do is force trailing slash except if in /wiki/. How would I do this?
Here is my current rule for it:
# force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
CodePudding user response:
You can add a RewriteCond
(condition) directive to create an exception for any URL that starts /wiki/
.
For example:
# force trailing slash
RewriteCond %{REQUEST_URI} !^/wiki/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
The !
prefix on the regex ^/wiki/
negates the expression, so it is successful when it does not match.
You will need to clear your browser cache.