You solve the problem from the wrong end. Let's start with the key question: where do such links come from?
If the source of "ugly" links is your site, then first of all you need to fix your site.
If the source of "ugly" links is other sites, then they should be negligible. When linking to your site, most people will use the addresses that your site gives out, rather than inventing something on their own and arranging slashes from the bald.
To search for sources of links, you can use a variety of analytics tools: Google Webmaster, Google Analytics, Yandex.Webmaster, Yandex.Metrica, etc.
Now, when the source of links is no longer there, it may turn out that search engines still use "ugly" links. If this bothers you, enter the canonical address on each page.
To do this, you can use <link rel='canonical'> , site maps, redirects, etc. In most cases, search engines cope with the detection of dulblirovannogo content on the site and take doubles as one page, and from the available URLs choose the most "beautiful", so you can not bother.
See Use canonical URLs .
.htaccess is a complex and inconvenient tool. You can add several rules to it, but the more complex the rules, the less readable the code becomes. If you run into the possibilities of .htaccess , then transfer all routing to the scripts and do not suffer.