views:

263

answers:

1

Hello

I use 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 fine, until I use these lines to redirect all requests to not files or dirs to index.php

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

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

Does anyone know why this wouldn't be working?

+1  A: 

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

So it now looks like this

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