Answer the question
In order to leave comments, you need to log in
How to count the number of Internet radio listeners?
There is an internet radio directory (an ordinary directory, nothing special about it).
I would like to introduce a rating by the number of daily listening to radio stations. The question is how to calculate the audience?
Answer the question
In order to leave comments, you need to log in
Here's what I did.
I broke $uri
it into separate words with regex.
That is, /data/countries
we get from ['data', 'countries']
Then I simply redirected to $uri, and did try_files $uri$2.json $uri/$2.json =404;
, which actually takes the second argument ( $2
), and adds to $uri
, at the end adds .json
and tries the file. If it finds it, it gives it back, if not, 404.
The whole code:
location /data {
rewrite (\w+) $uri break;
try_files $uri$2.json $uri/$2.json =404;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question