How can I remove multiple slashes?

Basically that, I have domain.com/ but if I visit domain.com// or with more slashes I would like to remove the extra ones and just leave one of them.

I found this but it's not working, I added on the .htaccess file.

IfModule mod_rewrite.c
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
    RewriteRule (.*) %1/%2 [R=301,L]
/IfModule

Keep in mind I used the homepage as an example, but it can happen on any page, adding extra slashes doesn't break the page but I need to be able to remove them so the user only sees one / at the end.

Topic url-rewriting htaccess Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.