采用通配符的重写规则并将其添加到目标页面

Rewrite Rule which takes wildcard characters and add it to the destination page

我需要一个重定向到子域的重写规则,但需要从通配符到目标页面的所有内容

例如:

如果 https://example.org/product/abcde 被调用,重定向应该去 https://new.example.org/product/abcde

我已经拥有的是:

RewriteRule ^/product/(.*)$ https://new.example.org/product [R=301,L]

但是这个规则 "forgets" 重定向中 /product/ 之后的所有内容

是否可以将通配符添加到新的URL?

我试过的是:

RewriteRule ^/product/(.*)$ https://new.example.org/product/(.*) [R=301,L]

但随后重定向转到 URL

https://new.example.org/product/(.*)

而不是

https://new.example.org/product/abcde

我可以找到一个解决方案,它非常适合我的要求

RewriteRule ^/produkt(.*)(.*) https://new.example.org/produkt/ [R=301,L]

https://alvinalexander.com/web/apache-redirectmatch-examples-wildcard-301

找到了解决方案