Answer the question
In order to leave comments, you need to log in
How to combine the launch of php scripts from different directories?
Hello,
there are directories:
/home/data/ - this folder contains files (eg index.php, conf.php, admin/index.php) that need to be hidden from the user (but he can run them).
/home/user/ - user files in this folder.
Task:
ЕСЛИ (запрошенный http адрес соответствует файлу в папке /home/user/)
{
ТО вернуть клиенту этот файл
}
ИНАЧЕ
{
ЕСЛИ (файл /home/user/index.php существует)
{
ТО вызвать скрипт /home/user/index.php для обработки запроса
}
ИНАЧЕ
{
указать root -директорию /home/data/ и
ЕСЛИ (запрошенный http адрес соответствует файлу в папке /home/data/)
{
ТО вернуть клиенту этот файл
}
ИНАЧЕ
{
вызвать скрипт /home/data/index.php для обработки запроса
}
}
}
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location /admin {
try_files $uri /admin/index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9023;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
Answer the question
In order to leave comments, you need to log in
And what is the actual problem?
Nginx has nothing to do with it, all requests should go to index.php, and from there, with checking the rights, the necessary scripts should be connected, if you resolve through nginx, you will have more configs than php code.
Determine what to connect via $_SERVER['REQUEST_URI'].
You need to check for the existence of a file through file_exists.
You can start it with a simple include (there are options here, if necessary).
Difficulties will be with security, solved if you want to rummage access to an unlimited circle of people.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question