RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
Yeah, that’s it. So:
- /path/dir/ is redirected to /path/dir
- /path/dir/?a=1&b=2 is redirected to /path/dir?a=1&b=2