Answer the question
In order to leave comments, you need to log in
How to change nginx root at a specific url?
Good afternoon.
We have the following nginx config:
server {
listen 80;
server_name test.loc;
root /var/www/test;
error_log /var/log/nginx/mytest.log;
index index.html index.php;
location / {
index index.html index.php;
#try_files $uri $uri/ /index.php?$args;
set $root /var/www/test;
}
location /sample {
index index.html index.php;
#try_files $uri $uri/ /index.php?$args;
alias /var/www/test2;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
/var/www/test/index.php
/var/www/test2/index.php
/var/www/test2/sample/index.php
Answer the question
In order to leave comments, you need to log in
Maybe so?
location ~ ^/sample(.*)$ {
# ...
alias /var/www/test2/$1;
# ...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question