Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定以下网址:
www.example.com/old/items/itemid/detail
现在说我想将请求重定向到以下位置:
www.example.com/new/product/location/itemid
...当然,“itemid”是动态的,但始终是正好四个数字的序列。
如何在 .htaccess 中创建一个重定向规则,该规则将从原始 URL“捕获”“itemid”并重定向到 URL 末尾具有相同 itemid 的新位置?
RewriteRule ^old/items/(\d*)/detail$ /new/product/locations/$1 [L,R=301]
应该可以,但我还没有尝试过。基本上,(\d*)匹配任意长度的数字,并且可以使用$1.
(\d*)
$1