In my .htaccess file I know how to rewrite a friendly URL:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)$ /index.php?index=$1 [L,QSA]
So, www.example.com/doit → www.example.com/index.php?doit where index.php will handle the rest.
However, I want to handle trailing slashes as well. I can use:
RewriteRule ^(.+?)/?$ /index.php?index=$1 [L,QSA]
which does work, but the URL keeps the trailing slash. I also suspect that the page thinks it’s in the wrong directory.
What I would like to do is catch the trailing slash first and redirect it to a non-slashed version:
www.example.com/doit/ → www.example.com/doit → www.example.com/index.php?doit
Presumably then the URL will be fixed, and the rewrite will act as normal.
Is that possible?

