配置nginx访问新目录下的默认文件

配置nginx访问新目录下的默认文件

要让 Nginx 支持访问 html/bo 目录下的 index.php,你可以添加一个新的 location 块。以下是修改后的配置:

location /bo {
    root html;
    index index.php;
}

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

在这个配置中,我们添加了一个名为 /bo 的新的 location 块,指定了根目录为 html,这个块会处理所有以 /bo 开头的请求。然后,我们指定了 indexindex.php,这意味着当访问 /bo 时,Nginx 将会尝试在 /bo 目录下查找 index.php 文件。

同时,原有的 location 块保持不变,继续处理所有以 .php 结尾的请求。

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容