D
D
Denis2020-10-07 11:14:49
Nginx
Denis, 2020-10-07 11:14:49

How to redirect nginx?

The essence of the question is this, it is necessary to make a redirect, that if a GET /car/car_city/?command= request comes in, it was redirected to /car/machine.php?command=

tried to do it in this form:

rewrite /car/car_city/?command=(.*)$ /car/machine.php?command=$1 last;


In the debug log I see the following:

2020/10/07 11:12:51 [notice] 62376#62376: *399173 "/car/car_city/?command=(.*)$" does not match " /cat/car_city/", client: xxx.xxx.xxx.xxx, server: xxxxx.xxxxx, request: "GET /cat/car_city/?command=check&txn_id=3956455137&account=68217004&sum=150.00&agreement_code=0 HTTP/1.1", host: "xxxxx.xxx"


What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-10-07
@Adamos

After ? go GET-parameters of the request.
nginx rewrite only processes the main part of the url, and your entry with a question mark is considered just a regular expression, in which one slash is optional.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question