zoukankan      html  css  js  c++  java
  • Nginx下配置ThinkPHP的URL Rewrite模式和pathinfo模式支持

    前面有关于lnmp环境的搭建,在此就不在赘述。下面就简述thinkPHP如何在nginx下开启url_rewrite和pathinfo模式支持

    主要有两个步骤:

    一、更改php.ini将;cgi.fix_pathinfo=0  改为cgi.fix_pathinfo=1

    二、更改nginx配置文件中php的location设置pathinfo模式:

    location ~ .php {
    root html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
    set $real_script_name $1;
    set $path_info $2;
    }
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
    include fastcgi.conf;
    }

    #nginx rewrite配置:

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

    如果你的thinkphp安装在二级目录下则rewrite配置如下:

    #yourdomain是所在的目录名称

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

  • 相关阅读:
    查看 lib 库信息
    评委打分(C++ 容器综合练习)
    二阶段12.16
    对搜狗输入法的使用心得
    二阶段12.14
    二阶段12.13
    二阶段12.12
    典型用户描述
    水王(课堂练习)
    一阶段11.21
  • 原文地址:https://www.cnblogs.com/weblm/p/5496518.html
Copyright © 2011-2022 走看看