.htaccess - ignore rule

I am using this line in my .htaccess file to automatically add a trailing slash if not present

rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ /$1/ [NC,R=301]

      

This works great until I use these lines to redirect all requests for files or dirs to index.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php

      

It now forwards the page, but doesn't add the trailing slash.

Does anyone know why this won't work?

+1


source to share


1 answer


I figured I added L for the last rule to the first rewriteRule.

So now it looks like



rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ /$1/ [NC,R=301,L]

      

+1


source







All Articles