#removes trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^.localhost$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301,L]
Above code segment removes trailing slashes, second code block is doing redirection from non-www to www.
In order for above code to work you will need to add two lines above it, telling Apache to enable rewrite module.
Options +FollowSymlinks
RewriteEngine on
So with that combined here is how your .htaccess file should look like
Options +FollowSymlinks
RewriteEngine on
#removes trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^.localhost$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301,L]
If you are using non-Apache server such as IIS let me know and I send you configuration for it.
Kind regards
Bojan