htaccess:将文章重定向到更深一层而不循环

htaccess: redirect article one level deeper without loop

我有一个 url 这样的:

https://example.com/product/my-product-name

我需要重定向到:

https://example.com/product/项目/我的产品名称

我尝试了多种解决方案,也尝试了我在 SO 上找到的解决方案,但是当我访问 /product(不应重定向)时我最终陷入了无限循环,并且当我调用 "old" 产品。

所以: https://example.com/product/项目/我的产品名称

重定向。

https://example.com/product/my-product-name 重定向到 https://example.com/product/项目/我的产品名称

https://example.com/product/https://example.com/product 不应重定向。

有人可以帮我解决这个问题吗?谢谢!

您可以在站点根目录 .htaccess:

中使用您的 最顶层规则 的重定向规则
RewriteEngine On

RewriteRule ^(product)/(?!item/)(.+)$ //item/ [L,NE,R=301]

确保在测试此更改之前清除浏览器缓存。