我目前正在使用以下内容将带有'.php'的所有请求发送到php引擎:
root /var/www/public;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
我想将所有请求/ login / ...发送到php服务器上的其他目录。我认为别名和try_files不能一起工作。我尝试过使用另一个'root',但它不起作用:
location ^~ /login/ {
root /var/www/login/etc/;
try_files $uri $uri/ /login$is_args$args;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
我怎样才能使这个工作,所以所有/ login / ...请求最终都是从php上的/ var / www / login / etc目录提供的。感谢。
答案 0 :(得分:0)
试试这个,
http {
...
map $request_uri $rot{
"~ /login" /var/www/login/etc/;
default <insert_default_root>;
}
server {
...
root $rot;
...
location / {...}
location ~ \.php$ {...}
...
}
...
}