Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 将带有查询的URL重定向到带有相同查询的新URL_Apache_.htaccess - Fatal编程技术网

Apache 将带有查询的URL重定向到带有相同查询的新URL

Apache 将带有查询的URL重定向到带有相同查询的新URL,apache,.htaccess,Apache,.htaccess,我希望在一个网站上创建一个重定向流,该网站可以采用以下URL: https://example.com/go/asset?tag=1234567 并可以将其重定向到: https://newexample.com?asset=1234567 我想我可能很接近,但似乎无法让它工作: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} /go/asset$ RewriteCond %{QUERY_S

我希望在一个网站上创建一个重定向流,该网站可以采用以下URL:

https://example.com/go/asset?tag=1234567
并可以将其重定向到:

https://newexample.com?asset=1234567
我想我可能很接近,但似乎无法让它工作:

<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>

重新启动发动机
重写cond%{REQUEST_URI}/go/asset$
RewriteCond%{QUERY_STRING}标记=\d{7}
重写规则^(.*)$https://newexample.com?asset=%1 [R=301,L]

我看到了一些类似的例子,它们为我的尝试提供了信息,但没有任何特定于我的用例的东西。非常感谢

我通过一些额外的测试就能够解决这个问题,下面是工作重定向:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(\basset\b=(\d{7}))$
RewriteRule ^(.*)$ https://newexample.com?asset=%2 [R=302,L]
</IfModule>

重新启动发动机
RewriteCond%{QUERY_STRING}^.*(\basset\b=(\d{7}))$
重写规则^(.*)$https://newexample.com?asset=%2 [R=302,L]
该测试工具特别有用: