Nginx+php-fpm下PATHINFO的配置(隐藏index.php,thinphp)

如果是新手的话推荐去看  http://blog.sina.com.cn/s/blog_6d579ff40100wi7p.html

下面的配置是我在从apache转到Nginx 对ThinkPHP的PATHINFO模式配置的,
1:根目录为/var/www/html
2:有两个manager和server目录,
     如 请求 /manager/test/ 和 /server/test/ 都会定向到manager/index.php和server/index.php
3: 其他所有的请求都定向到 /index.php

本人Nginx版本1.6.1 php版本 5.4.5

 access_log  logs/ww2_com_80.log  main;
          root /var/www/html;
          index index.htm index.html index.php;
          default_type 'text/plain';
     
          location ~ \.php { 
             
                 fastcgi_pass 127.0.0.1:9000;
                 fastcgi_index index.php;
                #加载Nginx默认"服务器环境变量"配置
                 include fastcgi.conf;
             
               fastcgi_split_path_info  ^(.+\.php)(/.*)$;
            
               fastcgi_param PATH_INFO $fastcgi_path_info;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               fastcgi_param SCRIPT_NAME $fastcgi_script_name;
          }
          
  
                    
          location ~ /(server|manager)($|/)(.*) {
                try_files  $uri  /$1/index.php$2$3?$query_string;       
          }#$1, $2 ,$3 分别对应了上面三个括号匹配的内容
          
          location / {
               try_files  $uri  /index.php$uri?$query_string; 
               #使用try_files 做定向必须在最后指定query_string变量,否则php取不到GET请求参数
        }

上面配置,有问题的地方大家指出来。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值