I
I
Ilya T.2017-02-05 11:47:06
Nginx
Ilya T., 2017-02-05 11:47:06

How to look for files in nginx elsewhere?

Please help with Nginx config.
It is necessary that if the file is not found in the target directory - look for it in another directory.
Those. if it was not possible to find
sitename.com/folder/filename.ext
give
stename.com/defaultfolder/sitename.ext
In this case, the folder can be anything.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2017-02-05
@Insaned

location / {
      try_files $uri $uri/ @storage;
    }

    location @storage {
      rewrite ^/.+/(.+)$ /defaultfolder/$1;
    }

A
Arman, 2017-02-05
@Arik

try_files ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question