重定向,但保留查询字符串

Redirection, but preserve the query string

是否可以创建重定向,但保留查询字符串?

例子,原URL:

`http://example.com/listing/?search_query=anykeyw&tax_location=newyork&wpas=1`

重定向到页面

 `http://example.com/new-york/?search_query=anykeyw`

保留 ?search_query=anykeyw,其中包含广告关键字和列表关键词...

有什么建议吗?

您可以在根目录中使用它 .htaccess:

RewriteCond %{QUERY_STRING} tax_location=newyork [NC]
RewriteCond %{QUERY_STRING} search_query=([^&]*) [NC]
RewriteRule ^listing/$ new-york/?search_query=%1 [NC,R,L]