对于ThinkPHP的URL访问路劲如:http://域名/index.php/Index/BlogTest/read,原先的Nginx的是不支持的pathinfo路劲的,导致你在thinkPHP5上面测试的时候,输入相应的URL也不会提示模块名,控制器名或者方法名错误,而是出现一个404找不到的错误,那是因为Nginx无法解析这样的链接,下面讲讲如何配置:

首先找到   nginx.conf

1、只实现pathInfo

笔者的位置在   /usr/local/nginx/conf 下

vim /usr/local/nginx/conf/nginx.conf

  1. location ~ \.php {    #去掉$
  2. root          H:/PHPServer/WWW;  笔者这里默认是 html;
  3. fastcgi_pass   127.0.0.1:9000;
  4. fastcgi_index  index.php;
  5. fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句
  6. fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
  7. fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  8. include        fastcgi_params;
  9. }

这样就实现了nginx 支持pathInfo

2、实现完全支持tp5 隐藏index.PHP 以及支持 pathinfo     栗子:

    1. server {
    2. listen       8082;
    3. server_name  localhost;
    4. charset utf-8;
    5. access_log  logs/host.access.log  main;
    6. root /usr/local/nginx/html/thinkphp/public;
    7. index  index.html index.htm index.php;
    8. location / {
    9. if (!-e $request_filename) {
    10. rewrite ^(.*)$ /index.php?s=$1 last;
    11. break;
    12. }
    13. }
    14. error_page   500 502 503 504  /50x.html;
    15. location = /50x.html {
    16. root   html;
    17. }
    18. location ~ \.php$ {
    19. fastcgi_pass   127.0.0.1:9000;
    20. fastcgi_index index.php;
    21. include fastcgi_params;
    22. set $real_script_name $fastcgi_script_name;
    23. if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
    24. set $real_script_name $1;
    25. set $path_info $2;
    26. }
    27. fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    28. fastcgi_param SCRIPT_NAME $real_script_name;
    29. fastcgi_param PATH_INFO $path_info;
    30. }
    31. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
    32. expires 30d;
    33. access_log off;
    34. }
    35. location ~ .*\.(js|css)?$ {
    36. expires 7d;
    37. access_log off;
    38. }
    39. }

tp 在Nginx上各种404的更多相关文章

  1. tp5 url 线上访问 在nginx 上 出现404错误,解决办法(1.80nginx 配置 pathInfo)

      对于ThinkPHP的URL访问路劲如:http://域名/index.php/Index/BlogTest/read,原先的Nginx的是不支持的pathinfo路劲的,导致你在thinkPHP ...

  2. nginx上传模块nginx_upload_module和nginx_uploadprogress_module模块进度显示,如何传递GET参数等。

    ownload:http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gzconfigure and make : . ...

  3. nginx上如何支持.htaccess伪静态转向

    我们知道在apache上有一个常用的功能.htaccess转向,只要apache编译的时候指明支持rewrite模块就可以了. 但是换到nginx上方法会有一点不一样,网上很多人说把.htaccess ...

  4. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

  5. nginx上支持.htaccess伪静态的配置实例

    本文介绍下,在nginx上配置.htaccess伪静态的方法,有需要的朋友参考下吧. 在apache上.htaccess转向,只要apache编译的时候指明支持rewrite模块即可. 但是换到ngi ...

  6. apache上.htaccess转向nginx上配置.htaccess伪静态规则

    nginx上配置.htaccess伪静态规则 在apache上.htaccess转向,只要apache编译的时候指明支持rewrite模块即可. 但是换到nginx上方法会有不同,有人说把.htacc ...

  7. 在Nginx上部署ThinkPHP,解决Pathinfo问题

    在Nginx上部署ThinkPHP,解决Pathinfo问题 事实上.要解决nginx不支持pathinfo的问题.有两个解决思路,一是不使用pathinfo模式,二是改动nginx的配置文件,使它支 ...

  8. Nginx之伪404( root与alias )

    目录 一.现象 二.root与alias的区别 三.建议 四.写在最后 一.现象   人类善于伪装,机器某些时候也善于伪装:Nginx请求看到404,第一反应就是文件不存在:但我们去检查的时候,它就正 ...

  9. nginx上部署python web

    nginx上部署python web http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

随机推荐

  1. hibernate框架总结

    实体类编写规则1 实体类里面属性私有的 2 私有属性使用公开的set和get方法操作 3 要求实体类有属性作为唯一值(一般使用id值) 4 实体类属性建议不使用基本数据类型,使用基本数据类型对应的包装 ...

  2. NetOps Defined

    https://www.logzilla.net/2017/06/20/the-network-operations-top-5.html

  3. mengento 数据库模型

  4. ZOJ 3203

    很简单的一题,注意墙上的影子是放大就行.用三分. #include <iostream> #include <cstdio> #include <cstring> ...

  5. 24岁菜鸟,能一个人撑起App开发吗

     "疲惫吾心.怎样躲藏.四处荒芜,怎话忧伤?"临近中秋,看到艾瑞斯的QQ签名,无尽的伤感.这个年仅24的青年.连续3年没有回家了,近期一个月总是失眠,没有家人的陪伴,就连女朋友 ...

  6. Geeks - Range Minimum Query RMQ范围最小值查询

    使用线段树预处理.能够使得查询RMQ时间效率在O(lgn). 线段树是记录某范围内的最小值. 标准的线段树应用. Geeks上仅仅有两道线段树的题目了.并且没有讲到pushUp和pushDown操作. ...

  7. kentico中提示Message: An invalid SQL query was used.

    在调用CMSAbstractWebPart类的GetValue方法的时候出错. namespace CMS.PortalEngine.Web.UI{ /// <summary> /// B ...

  8. hdoj--1251--统计难题(字典树)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others) Total Subm ...

  9. SQL语句之Insert

    插入常见的3种形式: 单条插入, 批量插入, 返回刚插入行的id http://www.cnblogs.com/yezhenhan/archive/2011/08/17/2142948.html

  10. sql语句获取本周、本月、本年数据

    本周:select * from table where datediff(week,C_CALLTIME,getdate())=0     --C_CALLTIME 为日期字段本月:select * ...