Using .htaccess, I want to redirect all the pages which contains --nocolor- at the end of their url. I want redirect them to the same url without the match.
Example:
https://www.test.com/products/test--nocolor-
to
https://www.test.com/products/test
What I've tried is
RewriteCond %{REQUEST_URI} (--nocolor-)
and that is working but I cannot get the right url while rewriting. I've tried
RewriteRule ^products/([^/]*)(?=--nocolor-) /$1 [R=301,L]
RewriteRule ^(.+)(?=--nocolor-) /$1 [R=301,L]
RewriteRule ^.*(?=--nocolor-) /$1 [R=301,L]
but I always end up with $1 empty. What do I do wrong?