问题
I want to redirect anything that comes directly to my server with perticuler query string to other location in same domain.
If user comes to
http://www.mydomain.com/?abc=js9sd70s
I want to redirect it to
http://www.mydomain.com/otherpath/?abc=js9sd70s
the query string ?abc=js9sd70s
should be the same to new url.
Please suggest nginx config file.
I have tried most of the alternative for below code. by keeping '\' before ? and = sign.
location ~ /?abc=.* {
rewrite ^/(.*)$ http://www.mydomain.com/otherpath/$1 permanent;
}
Please suggest me this location change.
回答1:
Short answer, try this configuration:
location = / {
if ( $arg_abc ) {
rewrite ^ /otherpath/ permanent;
}
}
来源:https://stackoverflow.com/questions/11305851/nginx-location-regexp-for-query-string