zoukankan      html  css  js  c++  java
  • nginx完美支持thinkphp3.2.2(需配置URL_MODE=>3 rewrite兼容模式)

    来源:http://www.thinkphp.cn/topic/26637.html

    环境:nginx 1.6,thinkphp3.2.2

    第一步,修改server块

    server {
         listen   80;
         server_name  www.domain.com domain.com;
         error_page   404              /404.html;
         error_page   500 502 503 504  /50x.html;
     #这个location块处理动态资源请求.
         location ~  .php   {
             root /data0/htdocs/www;
             fastcgi_pass   127.0.0.1:9000;
             include        fastcgi.conf;       
         }
         #这个location处理能处理所有的静态资源
        location / {
             root   /data0/htdocs/www;
             index  index.php index.html index.htm;
             #如果请求资源既不是静态目录资源(目录资源就是请求该目录下的默认首页index指令指定的默认资源),
             #也不是静态文件资源时候,就需要脚本动态生成,重写后重新用第一个处理动态请求的location块处理。
            if (!-e $request_filename){
                 #一定要用(.*)匹配整个URI,包含URI第一个字符反斜杠/
                 rewrite ^(.*)$ /index.php?s=$1 last;
             }
         }
     }
    

      

    第二步:打开thinkphp框架的配置文件convention.php,

    修改URL_MODEL=>3,采用rewrite兼容模式,并且修改
    'VAR_PATHINFO'=> 's', 重写时我们用的是s=""的形式.

    第三步:在浏览器输入:www.domain.com,结果如下:

    :)

    欢迎使用 ThinkPHP!

    [ 您现在访问的是Home模块的Index控制器 ]

    第四步:在浏览器中输入URL时候,还是用rewrite形式的url,就是不要输入入口文件了,其它的不变,例如:
    http://www.domain.com/module/controler/action/参数1/值1/参数2/值2/

    网址中不再需要输入入口文件index.php了,因为在刚才重写时我们已经指定好了入口文件index.php。

    注意不推荐用rewrite兼容模式,推荐用rewrite模式:
    http://www.thinkphp.cn/topic/26657.html

  • 相关阅读:
    php数组·的方法1-数组的操作
    第十一章:DOM扩展
    第十章:DOM
    hxq的库
    第八章:BOM
    第七章:函数表达式2
    第七章:函数表达式
    第五章:引用类型(一)-Object和Array
    舌尖上的程序猿
    计算矩阵运算的乘法次数
  • 原文地址:https://www.cnblogs.com/morgan363/p/11686887.html
Copyright © 2011-2022 走看看