T
T
taaadm2017-08-29 13:48:01
Nginx
taaadm, 2017-08-29 13:48:01

How to add extension to uri in nginx?

It is necessary that nginx requests like:
localhost/zbx/$filename be
remade into
localhost/zbx/$filename.jpg

location /zbx/ {
              rewrite ^[\w|\d|\ |\_|\-]+(?!\.pdf)$  $1.jpg permanent;
              return 301;
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2017-08-29
@xtreme

location ~ ^/zbx/ {
  try_files $uri $uri.pdf =404;
}

Naturally, root must be registered, otherwise the files will be searched in /etc/nginx.
Info: https://nginx.ru/en/docs/http/ngx_http_core_module...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question