[英]Redirect URL with query to new URL with same query
I am looking to create a redirection flow-through on a website that can take a URL such as:我希望在可以采用 URL 的网站上创建重定向流程,例如:
https://example.com/go/asset?tag=1234567
And can redirect it to:并可以将其重定向到:
https://newexample.com?asset=1234567
I think I might be close, but can't seem to get it working:我想我可能很接近,但似乎无法让它发挥作用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} /go/asset$
RewriteCond %{QUERY_STRING} tag=\d{7}
RewriteRule ^(.*)$ https://newexample.com?asset=%1 [R=301,L]
</IfModule>
I saw a few similar examples that have informed my attempt, but nothing specific to my use case.我看到了一些类似的例子,这些例子告诉了我的尝试,但没有针对我的用例。 Many thanks in advance!
提前谢谢了!
I was able to figure this out with some additional testing, here's the working redirect:我能够通过一些额外的测试来解决这个问题,这是有效的重定向:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(\basset\b=(\d{7}))$
RewriteRule ^(.*)$ https://newexample.com?asset=%2 [R=302,L]
</IfModule>
This testing tool was particularly helpful:这个测试工具特别有用:
https://htaccess.madewithlove.be/ https://htaccess.madewithlove.be/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.