php - nginx change root on specific url -
i have 1 nginx http server configuration this:
server { listen 80; server_name test.loc; root /var/www/test; location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.+)$; set $fsn /index.php; if (-f $document_root$fastcgi_script_name){ set $fsn $fastcgi_script_name; } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param script_filename $document_root$fsn; fastcgi_param path_info $fastcgi_path_info; fastcgi_param path_translated $document_root$fsn; fastcgi_read_timeout 180; } location / { index index.html index.php; try_files $uri $uri/ /index.php?$args; } location /sample/ { root /var/www/test2/; } }
i want address http://test.loc/sample
root in folder /var/www/test2
no matter how tried, displays contents of /var/www/test
.
thank in advance.
upd:
now have 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$ { #try_files $uri =404; #fastcgi_split_path_info ^(.+\.php)(/.+)$; #fastcgi_split_path_info ^(.+\.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; } }
all works fine, when content of url http://test.loc/sample/
see content /var/www/test2/sample/index.php
.
displayed /var/www/test2/index.php
any ideas? thanks.
Comments
Post a Comment