Remove just one GET parameter from url and rewrite another if a certain GET param isn't present - htaccess
Assuming your parameters are sometimes product
and always retailer
and site
(in that order), your rules should look like this
# first conditionRewriteCond %{HTTP_HOST} ^www\. [NC]RewriteCond %{QUERY_STRING} ^product=([^&\s]+)&retailer=([^&\s]+)&site=test$ [NC]RewriteRule ^$ /?product=%1&retailer=%2 [R=301,L]# second conditionRewriteCond %{HTTP_HOST} ^www\. [NC]RewriteCond %{QUERY_STRING} ^retailer=([^&\s]+)&site=test$ [NC]RewriteRule ^$ /retailer/%1? [R=301,L]
Try with below rules I am assuming index.php as handler and assuming other constraints are handled by you.
RewriteCond %{QUERY_STRING} ^product=([^/]+)&retailer=([^/]+)&site=([^/]+)$RewriteRule ^ index.php?product=%1&retailer=%2 [R=301]RewriteCond %{QUERY_STRING} ^retailer=([^/]+)&site=([^/]+)RewriteRule ^ /retailer/%1? [R=301]