请问,在nginx里面,怎样设置pathinfo,效果需和在apache里面一致

newpeng 2018-12-12 12:00:33
先说目录环境

根目录[one 为当前项目根目录]下面有两个目录 public,app
入口文件为 public/index.php
自己写的php程序放在 app 下面


http://127.0.0.1/one/public/test/v1.php
http://127.0.0.1/one/public/test/v1.html
这两个地址,apache下面都能正常访问,但是,第一个地址,在nginx里面无法访问,总说 【File not found.】,换成下面地址才能正常访问
http://127.0.0.1/one/public/index.php/test/v1.php

请问,需要如何设置nginx配置,才能 像 apache那样直接访问 http://127.0.0.1/one/public/test/v1.php,而不用在public后面加一个 inde.php
nginx配置如下

server
{
listen 80;
server_name 192.168.2.88;
charset utf-8;
autoindex on;
index index.php;
root /home/web;
location / {
root /home/web;
expires 60m;
}

location /one/public/*.php {
if (!-e $request_filename){
rewrite ^/one/public/(.*)$ /one/public/index.php?s=$1 last;
}
}
location ~ .*\.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.html,index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME /home/web$fastcgi_script_name;
include fastcgi_params;
}
}
...全文
164 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
newpeng 2018-12-15
  • 打赏
  • 举报
回复
搞定了,在 .htaccess 中按如下规则设置就可以了 rewrite ^/one/public/(.+).php$ /one/public/index.php?$1 last;
newpeng 2018-12-12
  • 打赏
  • 举报
回复
没有nginx栏目,只好发apache下面了。

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧