With Apache, how can I 301 any URLs that have double dashes to a single dash version?

domain.com/my-reg--url-here/ -> domain.com/my-reg-url-here/

domain.com/stuff/yeah/this--url-goes-somewhere/?id=100 -> domain.com/stuff/yeah/this-url-goes-somewhere/?id=100

I'm assuming that I will also need to add the N, QSA, and 301 flags?

  • There are numerous examples on the site. Failing that, it would be better if you posted what you have tried. Apr 1 at 23:50
  • Instead of adding 301 redirects you should identify the URLs linking to the URLs with double dashes and correct the links to point to the correct location as redirects will bind link juice, add latencies and consume crawl budget. Adding those redirects is only a valid solution if you have no control over the incomming links e.g. for external links. Apr 2 at 15:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.