zoukankan      html  css  js  c++  java
  • Nginx配置二级子目录示例

    本配置示例在ThinkPHP5 环境下亲测有效,二级目录配置与根目录配置完全独立。主要是通过 ^~ 把sub路径的路由全部接收过来,然后在子location里面进行二次路由和解析,比较方便灵活。之前一直以为location是不能嵌套的,通过这次实践,发现这样用的好处了,确实很方便。

    server {
        listen       80 ;
    
        index        index.php index.html;
    
        location ^~ /sub/ {
    	set  $subroot /home/peaksite/public/;
            alias $subroot;
            if ( !-e $request_filename) {
                rewrite ^/sub/(.*)$ /sub/index.php/$1 last;
                break;
            }
            location ~ .php {
                fastcgi_pass   127.0.0.1:9000;
                set $scriptname '';
                set $pathinfo '';
    
                if ( $uri ~ ^/sub/(.+.php)($|/.+) ) {
                    set $scriptname $1;
                    set $pathinfo $2;
                }
    
                fastcgi_param  SCRIPT_FILENAME  $subroot/$scriptname;
                fastcgi_index    index.php?IF_REWRITE=1;
                fastcgi_param    PATH_INFO    $pathinfo;
                fastcgi_param    SCRIPT_FILENAME    $subroot/$scriptname;
                include fastcgi_params;
            }
        }
    
    }
    

      

      

  • 相关阅读:
    使用JSON.NET实现对象属性的格式化的自定义
    AspNetCore项目-Service注入或覆盖
    发布Nuget
    收藏
    工具
    快捷键大全
    SqlServer分页查询语句
    面试相关
    Eratosthes algrithm 求素数
    code training
  • 原文地址:https://www.cnblogs.com/theluther/p/9320510.html
Copyright © 2011-2022 走看看