我在/ todos /
中添加了一个位置块,以从子URI(仅)提供Laravel应用程序location /todos {
try_files $uri $uri/ /todos/$query_string;
index index.php index.html index.htm;
root /index.php;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME /opt/bitnami/nginx/html/todos/public/index.php;
fastcgi_param QUERY_STRING $query_string;
include fastcgi_params;
}
}
但是进入/ todos / URI不起作用(禁止访问403),它要求我实际输入“ index.php”-因此Laravel仅适用于/todos/index.php。
我在做什么错了?
更新: 工作配置:
location /todos {
try_files $uri $uri/ /todos/index.php?$query_string;
index index.php index.html index.htm;
root /opt/bitnami/nginx/html/todos/public/;
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME /opt/bitnami/nginx/html/todos/public/index.php;
fastcgi_param QUERY_STRING $query_string;
include fastcgi_params;
}
}
答案 0 :(得分:1)
您的根必须是:
root $directory_of_your_index.php_file;
然后在“位置”中添加:
try_files $uri $uri/ /index.php?$query_string;