【nginx】 web-server 多文件入口访问
文章目录
访问需求示例
需要访问如下 url:localhost/info.phplocalhost/detail.php
服务端 server-root 目录结构:
➜ ~ tree public
public
├── detail.php
└── info.php
问题
我们习惯配置 nginx 的 web 服务为 单入口,即:
root /opt/pro/public;
index index.php index.html;
多入口 nginx 配置
利用
nginx变量$uri动态配置SCRIPT_NAME,实现web多入口访问
server {
listen80;
server_name localhost;
index index.php;
root /opt/pro/public;
location ~* \.php {
try_files $uri $uri/ /$uri?$query_string;
set $php_script $uri;
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME $document_root/$php_script;
fastcgi_param SCRIPT_NAME /$php_script;
}
}

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论