zoukankan      html  css  js  c++  java
  • 让thinkphp 5 支持pathinfo 的 nginx ,去掉index.php

        在TP5.0中查阅tp5官方文档,注意:5.0取消了URL模式的概念,并且普通模式的URL访问不再支持。
    phthinfo 是什么?
    PHP中的全局变量$_SERVER['PATH_INFO']是一个很有用的参数,众多的CMS系统在美化自己的URL的时候,都用到了这个参数。
    对于下面这个网址:
    http://www.test.com/index.php/foo/bar.html?c=index&m=search

    我们可以得到 $_SERVER['PATH_INFO'] = ‘/foo/bar.html’,而此时 $_SERVER['QUERY_STRING'] = 'c=index&m=search';

    通常,我们最初开始PHP程序编写的时候,都会使用诸如: http://www.test.com/index.php?c=search&m=main 这样的URL,这种URL不仅看起来非常奇怪,而且对于搜索引擎也是非常不友好的。
    很多搜索引擎收录的时候,都会忽略Query String之后的内容,google虽然不会忽略Query String,但是对于其他不含Query String的页面,会给于比较高的PR值。
      tp5默认不支持自动转换生成?s=/xxxx这种形式的url,关于Nginx的path_info可以参考以下方法:
    server {
    listen 80;
    root /var/www/html/health_data;
    index index.html index.htm index.php;
    server_name uuu.xxx.com;

    location / {
    try_files $uri $uri/ =404;
    if ( -f $request_filename) {
    break;
    }
    if ( !-e $request_filename) {
    rewrite ^(.*)$ /index.php/$1 last;
    break;
    }
    }
    location ~ .+.php($|/) {

    fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    fastcgi_param PATH_INFO $fastcgi_path_info; #加上这一句就可以跑了

    include snippets/fastcgi-php.conf;
    }
    }
  • 相关阅读:
    抽卡 状压DP+期望DP+系数递推
    20190903考试反思
    20190823考试反思
    约瑟夫类问题研究
    树位DP
    20190823考试反思
    20190820考试反思
    20190818考试反思
    20190817考试反思
    PowerBuilder--Aes128加解密
  • 原文地址:https://www.cnblogs.com/wtcl/p/6490530.html
Copyright © 2011-2022 走看看