Answer the question
In order to leave comments, you need to log in
How to change root in nginx?
There is a working site config.
server {
listen 80;
root /var/www/html/frontend/web;
index index.php;
charset utf-8;
client_max_body_size 8M;
error_log /dev/stderr;
access_log /dev/stdout;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|xml|html|htm)$ {
access_log off;
add_header Cache-Control no-cache;
expires 1s;
}
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
location /admin {
alias /var/www/html/backend/web;
}
location / { ... }
Answer the question
In order to leave comments, you need to log in
Add another root inside the location, it will take precedence over the global one.
location ~ ^/admin/?(.+) {
set $root /backend/web;
try_files $root/$1 /$uri $root/$uri $root/index.php$is_args$args;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question