N
N
nllm2014-11-25 14:06:54
Nginx
nllm, 2014-11-25 14:06:54

How to write a rule for location in NGINX?

Website scripts are in the folder: /var/www
Part of the statics is in the folder: /var/static
I'm trying to write a rule that when accessing /poster/, take statics from /var/static
At the same time, do not pass the name of the poster folder
For example:
we access www .site.ru/poster/hashhashhash/213.jpg the
file is returned from /var/static/hashhashhash/213.jpg I
wrote a rule, but it turned out that it returns from: /var/static/poster/hashhashhash/213.jpg
location ~ ^/poster/.*\.(jpg|gif\png)$ {
root /var/static;
}
Help, confused :-)
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
brutal_lobster, 2014-11-25
@nllm

nginx.org/ru/docs/http/ngx_http_core_module.html#alias

L
Lynn "Coffee Man", 2014-11-26
@Lynn

location /poster/ {
  alias /var/static/;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question