简体   繁体   English

将查询字符串重定向到另一个查询字符串

[英]redirect query string to another query string

I am trying to 301 redirect a query string to another query string, but everything I am trying seems to be failing. 我正在尝试301将查询字符串重定向到另一个查询字符串,但是我尝试的所有操作似乎都失败了。

I am trying to accomplish this: 我正在努力做到这一点:

http://www.example.com/something?_dog to redirect to http://www.example.com/something?_cat http://www.example.com/page1?_dog to redirect to http://www.example.com/page1?_cat http://www.example.com/aboutus?_dog to redirect to http://www.example.com/aboutus?_cat http://www.example.com/something?_dog 重定向到 http://www.example.com/something?_cat http://www.example.com/page1?_dog 重定向到 http:// www .example.com / page1?_cat http://www.example.com/aboutus?_dog 重定向到 http://www.example.com/aboutus?_cat

and thousands of other pages, so i need to keep the current url/directory etc but just redirect it to use a different query string. 以及其他数千个页面,因此我需要保留当前的url /目录等,但只需将其重定向以使用其他查询字符串即可。 they will all be "?_dog" going to "?_cat" 他们全都是“?_dog”去“?_cat”

any help much appreciated 任何帮助非常感谢

You can use this code in your DOCUMENT_ROOT/.htaccess file: 您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代码:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^_dog$ [NC]
RewriteRule ^ %{REQUEST_URI}?_cat [L,R=302]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM