Reputation: 734
I want to use .htaccess to redirect directory structure and remove this string "-detail" from the end of all SEF url.
for example:
https://www.example1.com/shop/items/product-catalog/category/concrete-tiles-detail
redirect to
https://www.example2.com/product-catalog/category/concrete-tiles
The "category" part of the path is dynamic. and could even be comprised of several directories like
https://www.example1.com/shop/items/product-catalog/category1-2-or-3/sub-category/concrete-tiles-detail
the first rule works, but i have not found a solution for removing the string at the end.i tried this answer but its not working for this scenario.
RewriteEngine On
RewriteBase /
RewriteRule ^shop/items/product-catalog/(.*) https://www.example2.com/product-catalog/$1 [R=301,L]
RewriteRule ^(.*?)="\{\{-detail(.*)$ /$1$2 [R=301,L]
Upvotes: 0
Views: 108
Reputation: 96383
Just adding that part after the grouped match in the pattern (and anchoring the pattern at the end), should do the trick.
RewriteRule ^shop/items/product-catalog/(.*)-detail$ https://www.example2.com/product-catalog/$1 [R=301,L]
That second rule you tried, can be removed completely then.
Upvotes: 1