U
U
ujim2013-11-20 13:40:15
Nginx
ujim, 2013-11-20 13:40:15

How to change uri in nginx?

Tell me how to configure nginx
location config ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|html)$ {
expires max;
log_not_found off;
} So that /v0 example.ru/article/main.html
would be excluded from the incoming request
example.ru/article/v0/main.html or /v1 example.ru/ would be excluded from example.ru/img/v1/images.jpg img/images.jpg And the requested data was selected from the appropriate folders, that is, root/article/main.html root/img/images.jpg



Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dan Ivanov, 2013-11-20
@ujim

You can depict such a hell in the location:

rewrite ^/([^/]*)/([^/]*)/(.+\.(js|css|png|jpg|jpeg|gif|ico|html))$ /$1/$3 break;

Or if the number of "caught" directories is finite then:
rewrite ^/(img|article)/([^/]*)/(.+\.(js|css|png|jpg|jpeg|gif|ico|html))$ /$1/$3 break;

U
ujim, 2013-11-20
@ujim

Applied as
location ~* ^.+\.(jpg|jpeg|gif|png|bmp|ico|swf|html|htm|css|js)$ {
rewrite ^/([^/]*)/([^/ ]*)/(.+\.(jpg|jpeg|gif|png|bmp|ico|swf|html|htm|css|js))$ /$1/$3 last;
root /home/example;
access_logoff;
expires max;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question