I have many duplicated post and I wanted remove them but Google already indexed them. So the idea is redirect all post with pattern [-number] in the end of the url to the same URL without number
www.domain.com/category/post-title[-number]
to www.domain.com/category/post-title
Example:
www.domain.com/category/post-title/
www.domain.com/category/post-title-1/ --> www.domain.com/category/post-title/
www.domain.com/category/post-title-2/ --> www.domain.com/category/post-title/
www.domain.com/category/post-title-3/ --> www.domain.com/category/post-title/
www.domain.com/category/post-title-4/ --> www.domain.com/category/post-title/
www.domain.com/category/post-title-5/ --> www.domain.com/category/post-title/
www.domain.com/category/post-title-6/ --> www.domain.com/category/post-title/
I have tried some Rewrite Rules on the .htaccess but didn’t work at all.
For example this one:
#RewriteRule ^/(.+)-[0-9]+/$ /$1 R=301
(.+)
–> it will match the letters of the ‘post-title’
-[0-9]+/
–> It will match the ‘-‘ and the number of the tittle
Thanks!