Reputation: 10395
I want redirect urls like /catalogsearch/result/?q=[keyword]
to /products?keyword=[keyword]
. Whats wrong with following rule?
location ~ /catalogsearch/result/?q=(.*) {
rewrite ^ /products?keyword=$1 permanent;
}
Upvotes: 1
Views: 562
Reputation: 49702
The ?
and anything after it (the query string) is not part of the normalized URI used by the location
and rewrite
directives.
Assuming that there is only one parameter, you can access it using the $arg_
family of variables.
location = /catalogsearch/result/ {
return 301 /products?keyword=$arg_q;
}
Upvotes: 1