zoukankan      html  css  js  c++  java
  • [Nginx] Nginx配置PHP应用传递PATH_INFO变量

    这里比较兼容的处理是:

    server {
            listen       80;
            server_name  域名;
            root   路径;
            if (!-e $request_filename) {
                    rewrite ^/(.*)$ /index.php/$1 last;
                    break;
            }
            access_log  /var/log/nginx/域名-access.log;
            error_log  /var/log/nginx/域名-error.log;
            location / {
                index  index.php;
            }
    
            location ~ .php {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_read_timeout        60s;
                fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;
            }
    } 

    这里是非贪婪模式:

    fastcgi_split_path_info  ^((?U).+.php)(/?.+)$;

    (?U)表示对后面的子串进行非贪婪匹配

    fastcgi_split_path_info  ^(.+.php)(/.*)$; 这种是贪婪匹配,具体区别看下图

    非贪婪下,只匹配到第一个.php

    贪婪下匹配到最后一个.php

    开源作品

    GO-FLY,一套可私有化部署的免费开源客服系统,安装过程不超过五分钟(超过你打我 !),基于Golang开发,二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能
    github地址:go-fly
    官网地址:https://gofly.sopans.com

    赞赏作者

    微信交流

  • 相关阅读:
    ajax异步服务器获取时间
    JavaScript基本知识
    JavaScript使用button提交表单
    spring与hibernate整合
    Spring的事务属性
    注解方式实现Spring声明式事务管理
    svn的安装使用
    sbn
    恢复oracle中误删除drop掉的表
    ORA-20000: ORU-10027: buffer overflow, limit of 2000 bytes的解决办法
  • 原文地址:https://www.cnblogs.com/taoshihan/p/14566825.html
Copyright © 2011-2022 走看看