I seem like I am really close, however i can't quite understand this Apache RewriteRule to operate properly.

I've got a URL like http://mysite.com/product.php?view=true&ID=123 and I must redirect to http://mysite.com/some-page.But when the merchandise ID=456, then Let me redirect it to http://mysite.com/some-other-page.

And So I don't have to keep your query string for my destination Web addresses, however i do care what it really equals within the request because which will determine where I redirect the consumer to. I have been battling with attempting to understand ways to use the mod_rewrite %{QUERY_STRING} parameter, however i cannot get results.

Thanks ahead of time for the help!

This ought to help a bit.

RewriteCond %{QUERY_STIRNG} id=456
RewriteRule .* /some-other-page? [R,L]

Much more about Manipulating the Query String.

Such as this:

RewriteEngine On

RewriteCond %{QUERY_STRING} =view=true&ID=123
RewriteRule ^product\.php$ /some-page? [R=301,L]

RewriteCond %{QUERY_STRING} =view=true&ID=456
RewriteRule ^product\.php$ /some-other-page? [R=301,L]
  1. You have to match ^product.php in addition to query string. Used to do match FULL EXACT query string (both view=true and ID=123 have to be contained in EXACT order). If you want only partial match (e.g. ID=123 only), then replace =view=true&ID=123 by ID=123.

  2. Notice ? in the finish of recent URL -- this really is to eliminate existing query string. Without them /product.php?view=true&ID=123 is going to be rerouted as /some-page?view=true&ID=123.

  3. I have used 301 Permanent Redirect. You might want to change it out to 302 or whatever other redirect code you believe is much better.

  4. This will be put into .htaccess in in website root folder. If placed elsewhere some small fine-tuning might be needed.