好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

nginx下使用ThinkPHP框架rewrite以及二级目录问题 -

nginx下使用ThinkPHP框架rewrite以及二级目录问题

在nginx下配置thinkphp时,如果需要去除index.php这个默认的路径名,同时修改web服务对应的目录,就需要修改nginx下的default.conf这个里面的配置:

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

root修改web服务所在文件夹(视个人不同情况),然后抓取获取的url,通过正则抓取所对应的url:

location ~ \.php {          set  $script   $uri ;          set  $path_info   "/" ;           if  ( $uri  ~  "^(.+\.php)(/.+)" ) {            set  $script   $1 ;            set  $path_info   $2 ;          }            fastcgi_pass 127.0.0.1:9000;          #fastcgi_index index.php?IF_REWRITE=1;           include  fastcgi_params;          fastcgi_param PATH_INFO  $path_info ;          fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/xxxxx $script ;          fastcgi_param SCRIPT_NAME  $script ;       } 

最后修改对应的php文件设置path_info修改fastcgi的参数,这样就可以完成对nginx关于thinkphp去掉index.php的问题.

查看更多关于nginx下使用ThinkPHP框架rewrite以及二级目录问题 -的详细内容...

  阅读:87次