N
N
nepster-web2014-05-30 17:45:43
Nginx
nepster-web, 2014-05-30 17:45:43

How to organize the desired path in location, nginx ?

There was a situation when it is necessary to specify another root for the site.ru/admin url.
It looks like this:

location /admin {
        try_files $uri $uri/ /$yii_bootstrap?$args;
        root /var/www/site.ru/test/backend/web;
   }

Now the following problem has turned out, when requesting site.ru/admin, nginx tries to find index.php in the directory "/var/www/site.ru/test/backend/web/admin" instead of "/var/www/site.ru/ test/backend/web"
Creating a folder inside web is not an option. Tell me, please, how to solve such a problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kolger, 2014-05-30
@Kolger

Try alias instead of root.

V
Vlad Zhivotnev, 2014-05-30
@inkvizitor68sl

location /admin {
        try_files $uri $uri/ /$yii_bootstrap?$args;
        alias /var/www/site.ru/test/backend/web;
   }

This is how it will work. (well, assuming try_files is correct)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question