V
V
Vanes Ri_Lax2020-09-10 09:27:15
Nginx
Vanes Ri_Lax, 2020-09-10 09:27:15

Is it possible to make such a redirect to nginx?

Good afternoon!
There is a PHP code that works at the address:
domen.ru/index.php?id=131
I need that when the client contacts the address:
domen.ru/api/parametr1/parametr2
so that in fact all requests go to that code. That is, if the word api comes after the domain, then all requests should already go here:
domen.ru/index.php?id=131
And after api there can be several parameters, all parameters will be indicated through a slash. Is it possible to implement something like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-09-10
@vanesxl

Everything that starts with /api/ can be sent to /index.php?id=131 like this:
rewrite ^/api/ /index.php?id=131 last;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question