zoukankan      html  css  js  c++  java
  • nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法

    将一个thinkphp项目从apache环境移到nginx1.2上,怎奈,nginx这个版本默认不支持pathinfo模式

    首先,编辑nginx的虚拟主机配置文件

        location ~ .*.(php|php5)?$
            {
                    #原有代码
            }
    if (!-e $request_filename) { 
     rewrite  ^(.*)$  /index.php?s=$1  last; 
     break; 
      }

    #去掉$是为了不匹配行末,即可以匹配.php/,以实现pathinfo #如果你不需要用到php5后缀,也可以将其去掉 location ~ .php { #原有代码 #定义变量 $path_info ,用于存放pathinfo信息 set $path_info ""; #定义变量 $real_script_name,用于存放真实地址 set $real_script_name $fastcgi_script_name; #如果地址与引号内的正则表达式匹配 if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") { #将文件地址赋值给变量 $real_script_name set $real_script_name $1; #将文件地址后的参数赋值给变量 $path_info set $path_info $2; } #配置fastcgi的一些参数 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; }

    以上是在网上找的答案,事实上,只是加了这一段就可以了

    if (!-e $request_filename) {
       rewrite  ^(.*)$  /index.php?s=$1  last;
       break;
        }

    参考http://doc.thinkphp.cn/manual/hidden_index.html

    http://www.thinkphp.cn/topic/3138.html

    http://www.nginx.cn/426.html

  • 相关阅读:
    LeetCode_326. Power of Three
    LeetCode_303. Range Sum Query
    LeetCode_299. Bulls and Cows
    LeetCode_292. Nim Game
    LeetCode_290. Word Pattern
    LeetCode_283. Move Zeroes
    LeetCode_278. First Bad Version
    LeetCode_268. Missing Number
    LeetCode_263. Ugly Number
    LeetCode_258. Add Digits
  • 原文地址:https://www.cnblogs.com/walter371/p/4155831.html
Copyright © 2011-2022 走看看