Reputation: 809
No matter how hard I search for help with htaccess redirect/rewrite rules, I never seem to find an exact match for my problem. And with htaccess, you can't exactly wing it on the syntax!
Please help me redirect any traffic to:
/blue-widgets?param=value1
Needs to redirect straight to:
/blue-widgets/compare-widgets?param=value1
It's probably obvious but the redirect should not happen to any traffic to:
/blue-widgets (direct) OR /blue-widgets?param={any other value}
Thank you and Merry Christmas.
Upvotes: 1
Views: 124
Reputation: 785551
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)param=value1(&|$) [NC]
RewriteRule ^(blue-widgets)/?$ /$1/compare-widgets [L,NC,R=302]
Query string is by default carried over to target URL.
Upvotes: 1