I'm trying to set some very specific conditions on a url rewrite but I'm struggling.
Let's say I have a url like http://www.example.com/?product=test&retailer=test&site=test
In this instance (where product parameter is present) I just want to remove &site=test but leave the rest of the url untouched.
If product parameter isn't present, e.g. http://www.example.com/?retailer=test&site=test
I still want to remove &site=test and change ?retailer=test to /retailer/test so the full url would be http://www.example.com/retailer/test. I also only want this to happen on the root domain. Really struggling even just to remove site parameter...
I tried this:
RewriteCond %{QUERY_STRING} (?:^|&)sitechange=([^&]+) [NC]
RewriteRule ^$ ? [L,R=301]
but this removes all parameters in all instances
Also tried this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (.*)?&?site=[^&]+&?(.*)? [NC]
RewriteCond %{REQUEST_URI} /(.*)
RewriteRule .* %3?%1%2? [R=301,L]
but this does nothing. Finding it really hard to get my head around these rewrite rules. If anyone could help it would me much appreciated