Examples of redirects from pages with a slash to without a slash:
Example 1 – 301 redirect from slash to without slash
RewriteCond %{REQUEST_URI} !\? RewriteCond %{REQUEST_URI} !\& RewriteCond %{REQUEST_URI} !\= RewriteCond %{REQUEST_URI} !\. RewriteCond %{REQUEST_URI} ![^\/]$ RewriteRule ^(.*)\/$ /$1 [R=301,L]
If your site uses a CMS (for example, Opencart), then after adding the above conditions to .htaccess, the admin panel will stop working. Because it is necessary for the admin panel not to use a redirect from slash to without slash.
Example 2 – 301 redirect from slash to without slash (except admin panel)
RewriteCond %{REQUEST_URI} !\? RewriteCond %{REQUEST_URI} !\& RewriteCond %{REQUEST_URI} !\= RewriteCond %{REQUEST_URI} !\. RewriteCond %{REQUEST_URI} !^/admin/.*$ RewriteCond %{REQUEST_URI} ![^\/]$ RewriteRule ^(.*)\/$ /$1 [R=301,L]