I want to redirect to one query string URL to another:
example.com/product-category/search/?filter_grade-level=154
to
example.com/product-category/search/?filter_grade-level=k
Any thoughts what to add in .htaccess
?
I want to redirect to one query string URL to another:
example.com/product-category/search/?filter_grade-level=154
to
example.com/product-category/search/?filter_grade-level=k
Any thoughts what to add in .htaccess
?
You need to use mod_rewrite to check the query string. Try something like the following at the top of your `.htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(filter_grade-level)=154$
RewriteRule ^product-category/search/$ /$0?%1=k [R=301,L]
In the RewriteRule
substitution (ie. /$0?%1=k
), $0
is a backreference to the entire matched RewriteRule
pattern and %1
is a backreference to the captured group in the last matched CondPattern (ie. "filter_grade-level").
So, on success, /$0?%1=k
expands to:
/product-category/search/?filter_grade-level=k