The location
directive does not match on the query string. So you'll have to do something else.
I presume you have a large number of these to work with, so I would suggest using a couple of map
s. For instance:
map $arg_directoryid $mycategory {
11 hard-drive-cases;
12 some-other-category;
default ""; # would go to the homepage, change it to go to some other page
}
Then you would do a location
such as:
location /productcatalog.aspx {
return 301 $scheme://$host/$mycategory;
}
Make a second map
and location
for the $arg_productid
corresponding to productdetails.aspx
. If that one is exceptionally large, though, you might have performance issues, and need to scrap this and do some scripting to obtain the redirect from a database.
The map
s must be in your http
block, not within a server
block. If you are hosting multiple sites, the best place to put them, in my opinion, is immediately before the server
block that they correspond to.
Best Answer
The
Redirect
directive doesn't take a full URL as the "old" location.Try:
From the documentation: