Forum Moderators: phranque
From URL: http://oldsite.com/product_info.php?currency=EUR&products_id=61
To URL: http://www.newsite.com/new-url-blurb-61 http://www.newsite.com/new-url-blurb-61/?currency=EUR&products_id=61
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} product_info.php [NC]
RewriteCond %{QUERY_STRING} currency=EUR&products_id=61 [NC]
RewriteRule ^(.*)$ http://www.newsite.com/new-url-blurb-61/ [R=301,L]
</IfModule> [edited by: not2easy at 10:56 pm (utc) on Apr 17, 2017]
[edit reason] readability edit [/edit]
RewriteRule ^(.*)$ http://www.example.com/new-url-blurb-61/ [R=301,L]
RewriteRule ^(.*)$ http://www.example.com/new-url-blurb-61/? [R=301,L] The question mark means “get rid of the query string”. (Technically it means “replace the existing query string with whatever comes after the question mark”--which happens to be nothing.)
By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.