简体   繁体   中英

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.

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

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. they will all be "?_dog" going to "?_cat"

any help much appreciated

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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