Redirect url to non trailing slash / Remove trailing slash from url

This gives me headaches for a while now. I wish to do 301 redirect for all urls that end with trailing slash.
I tried multiple solutions found on this forum, but just cant get it working properly.

All links on site are already made without trailing slash at end and it would be quite a project to add trailing slash all over the site as site does not use navigation implemented in concrete5.

Google bugs me with few hundred duplicate title tags / ending slash url and url with no ending slash.
I get it how ending slash might be better depending on -f, -d, but still.

Automated job - sitemap also adds ending trail slash that i removed manually. Image block also ends url with slash.

Any suggestions what and where to change, that trailing slash would be removed from urls and all urls with slash do 301 redirect to non slash version?
Page is mostly indexed in google without trailing slash. And even though it might not be "such a huge problem" at the moment, we all know that this search engine gets more offensively oriented with every algorithm update.
For now i`m looking for working solution that doesn't include any addons.
Site still runs on btw.

View Replies:
ssrgspdkt replied on at Permalink Reply
you want to edit /config/site_process.php.
mhawke replied on at Permalink Reply
@ssrgspdkt... can you be more specific?
Spletnapot replied on at Permalink Reply
User mhawke just asked what i intended. Bit more specific solution would be of great help, as i`m back to google search and concrete forum/chit chat search where isn`t or i just cant find the proper solution.

If possible, could you paste the proper code solution for this?

site_process.php on my concrete install has just a few lines where i disabled "custom design".
Spletnapot replied on at Permalink Reply
Looks like bottom two lines removed ending url slash and did 301 redirect to non slash version through .htaccess. It works to some point, or at least until you logout and try to login again.

RewriteCond %{HTTP_HOST} !^\.domain\.com$ [NC]
RewriteRule ^(.+)/$http://%{HTTP_HOST}/$1 [R=301,L]