.htaccess - how to remove repeated words in url?
问题 What is the regex in .htaccess to go from those urls: example.com/hello-world-world example.com/hello-world-hello to this one: example.com/hello-world using RewriteCond like this: RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{REQUEST_URI} ^REGEX$ RewriteRule . %1 [R=301,L] 回答1: Removing all the duplicate words from slug is pretty tricky to be done in mod_rewrite only but here is a lookahead based regex rule than you can use: RewriteEngine On RewriteCond %{REQUEST_URI} ^/((?:[^-]*-)*)([^-