[英]Laravel on Nginx default / URI not working - requires “index.php” - Nginx config issue?
I've added a location block to serve a Laravel app from a sub URI (only) at /todos/ 我在/ 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;
}
}
But going to /todos/ URI doesn't work (serves up 403 Forbidden), it requires me to actually put in "index.php" - so Laravel only works with /todos/index.php. 但是转到/ todos / URI不起作用(保留403 Forbidden),它要求我实际输入“ index.php”-因此Laravel仅与/todos/index.php一起使用。
What am I doing wrong? 我究竟做错了什么?
UPDATE: Working config: 更新:工作配置:
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;
}
}
Your root needs to be: 您的根必须是:
root $directory_of_your_index.php_file;
And in Location add: 并在位置中添加:
try_files $uri $uri/ /index.php?$query_string;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.