C
C
Carry2018-12-06 12:42:39
Nginx
Carry, 2018-12-06 12:42:39

How to do nginx location on files in another folder correctly?

There is an address for example: news.site.ru
so that the link news.site.ru/auth/ opens index.php from the folder /var/www/news.site.ru/news/auth/
I have this:

location / {
        index /app.php;
     }
location  /auth/ {
    index /news/auth/index.php;
 }

everything works and the index file is returned.
Another interesting point, an example from office. site
location /i/ {
    root /data/w3;
}
в моем случае не работает! и с индексом и без
location /auth/ {
    root /news;
    index index.php
}

But the problem is different, I need all the files that will be further loaded from this link by AJAX, so that they are also taken from this folder:
An example file at /auth/get_data.php should be taken from /var/www/news.site. en/news/auth/get_data.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vman, 2018-12-06
@carryx

location ~ ^/auth/ {
    root /var/www/news.site.ru/news;
    index index.php;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question