0

I changed category urls on site. Old are like this:

www.example-name.com/category-name-exactly-same-keywords/

www.example-name.com/category-name-exactly-same-keywords/subcategory-name-exactly-same-keywords/

New URLs:

www.example-name.com/category-name/

www.example-name.com/category/subcategory-name/

I removed "-exactly-same-keywords" from category URLs.

In my .htaccess I have this:

# Category 301 redirection

RewriteRule ^-some-category-suffix(.*)$ $1 [L,R=301]

It is fine, if there is just one category level, it rewrite this:

www.example-name.com/category-name-exactly-same-keywords/

to:

www.example-name.com/category-name/

But, if there is more than one category level it removes only last

www.example-name.com/category-name-exactly-same-keywords/subcategory-name-exactly-same-keywords/

to:

www.example-name.com/category-exactly-same-keywords/subcategory-name/

------------------------------------------------------------------------------------------

How to rewrite (remove) all instances of "-exactly-same-keywords", if more than one in old URLs to new URLs without it?

Advanced SEO
  • 123
  • 1
  • 7

1 Answers1

1

Add the N flag to the RewriteRule, to make it repeat as many times as the rule matches. I'm not sure how that flag interacts with the L and R flags; I would start by taking both of those out, getting the rule working, then seeing which of them you can put back in.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47