I have a url like this:
https://example.com/product/my-product-name
I need to redirect to:
https://example.com/product/item/my-product-name
I tried multiple solutions, also solutions I've found here on SO, but I ended up on infinite loops when I accessed /product (which shall NOT redirect) and also multiple redirects when I called the "old" product.
So: https://example.com/product/item/my-product-name
shall NOT redirect.
https://example.com/product/my-product-name shall redirect to https://example.com/product/item/my-product-name
and
https://example.com/product/ and https://example.com/product shall NOT redirect.
Can anybody help me on this? Thanks!
You may use this redirect rule your topmost rule in site root .htaccess:
RewriteEngine On
RewriteRule ^(product)/(?!item/)(.+)$ /$1/item/$2 [L,NE,R=301]
Make sure to clear your browser cache before testing this change.