Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.*)/[^/]
RewriteRule ^(.*)$ http://example.com%1/ [L,R=301]
this has the (unintended, but cool) consequence of working recursively. for example, say a user enters a URL like so:
http://example.com/good/url/nonsense/morenonsense/wth/typo.bleh
.htaccess will rewrite it like so:
example.com/good/url/nonsense/morenonsense/wth/
which will be rewritten like
example.com/good/url/nonsense/morenonsense/
and so on, until we get to
example.com/good/url/
cool, huh?
the only caveat is that /good/url/ must contain an index file, or, at this point, you'll get a 404.
Bookmarks