S
S
Salavat Sitdikov2016-08-31 17:06:10
Nginx
Salavat Sitdikov, 2016-08-31 17:06:10

What location for nginx should be written so that trailing slash is not taken into account?

Issue resolved.

Answer: do not forget about the priorities between location in nginx. It was necessary to place the necessary rewrite above :)

Generally. There is a server in a distant country that stores statics (now).
And there is an old application in which the statics were stored in the root and the paths to the application were given in the following form:
/photo/2015-01-01/big-photo.jpg

Actually, since now the servers are not stored locally, I am trying to make nginx-rewrite so that when
http://mysupersite.net/photo/2015-01-01/bigphoto.jpg is requested, the request goes to http://tipacdn.yandex. no/sitename/photo/2015-01-01... .
Help, good people.
The main option, in which almost everything works, is
location ~/photo/(.*) {
return 301 http://tipacdn.яndex.net/sitename$1;

But in this case, the address with the picture must end with / - which leads to a not quite working method.
PS The option to remake the application is being considered and has already been taken into account. But now I'm interested in specifically addressing this issue.
P.S. What have you already tried?
location ~/photo/(.*)/(.*) {
return 301 http://tipacdn.яndex.net/sitename$uri;
}

location /photo {
rewrite ^/photo(.*)       http://tipacdn.яndex.net/sitename$1 permanent;
    }

and various combinations with (.*)(jpg|png|jpeg) and so on.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question