Answer the question
In order to leave comments, you need to log in
Nginx rewrite - how to get the value of multiple variables?
For the third day I have been trying to understand the rules of rewriting and how to write what, my head no longer cooks.
Tell me how to get the values 123 and 456
from an address like example.com/123/456.
in php script you need to get data by analogy with example.com/index.php?a=123&b=456. The names of the variables (a and b) are constant, they should not be passed.
With one variable, everything is clear - I did try_files $uri $uri/ /index.php?a=$uri;
for two it is necessary to do a rewrite?
Or is it necessary to implement and process the $_GET['a'] value by means of the script itself, which now gives /123/456 (i.e. the entire line)
location / {
try_files $uri $uri/ /index.php?a=$uri;
}
location ~ .php$ {
include /etc/nginx/conf.d/fastcgi_params.conf;
.... другие параметры...
}
Answer the question
In order to leave comments, you need to log in
1. (x)(y ) nobody canceled $1$2 and so on.
2. SET also works. what is the problem ?
if ($host ~* ^(www\.)(.+)) {
set $HBW $2;
root /var/www/$HBW/web;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question