【发布时间】:2020-10-04 13:17:38
【问题描述】:
我想使用 .htaccess 来重定向目录结构并从所有 SEF url 的末尾删除这个字符串“-detail”。
例如:
https://www.example1.com/shop/items/product-catalog/category/concrete-tiles-detail
重定向到
https://www.example2.com/product-catalog/category/concrete-tiles
路径的“类别”部分是动态的。甚至可以由几个目录组成,例如
https://www.example1.com/shop/items/product-catalog/category1-2-or-3/sub-category/concrete-tiles-detail
第一个规则有效,但我没有找到删除末尾字符串的解决方案。我尝试了this 答案,但它不适用于这种情况。
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]
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite