php - Try_files 没有命中 PHP(NginX 配置)

标签 php nginx

下面是我的 nginx.conf。

如果文件不存在,/index.php 可以正常使用。

但是当我的 URL 是 /foo/bar =>/foo/bar/index.php 时,通过下载作为 PHP 源代码。

有什么想法吗?

try_files $uri $uri/ $uri/index.php /index.php;

location ~ \.php$ { 
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

最佳答案

解决方案是添加index index.php

    index index.php

    try_files $uri $uri/ $uri/index.php /index.php;

    location ~ \.php$ { 
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

关于php - Try_files 没有命中 PHP(NginX 配置),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12091386/

相关文章:

javascript - 循环遍历数据库中的元素时如何显示视觉反馈?

ubuntu - 使用 HTTPS 的 IP 给出 "Your connection is not private"[Nginx/Ubuntu]

nginx 500 内部服务器错误

reactjs - 将所有请求发送到 index.html 除了某些扩展

php - NGINX 默认站点有效,但另一个端口上的站点无效

php - 需要想法只显示一些像素并将剩余像素变灰

php - 正则表达式来检查字符串是否有中文字符

php - 从 Left Join 中的第一个表获取变量

javascript - 国际化静态网站示例

php - 使用 MySql 和 php 获取视频