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請求參數
        }

上面配置,有問題的地方大家指出來。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章