对于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. BA--步进电机工作原理

    步进电机是将电脉冲信号转变为角位移或线位移的开环控制元步进电机件.在非超载的情况下,电机的转速.停止的位置只取决于脉冲信号的频率和脉冲数,而不受负载变化的影响,当步进驱动器接收到一个脉冲信号,它就驱动 ...

  2. Codeforces Round #136 (Div. 1) B. Little Elephant and Array

    B. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input ...

  3. 初探swift语言的学习笔记十(block)

    作者:fengsh998 原文地址:http://blog.csdn.net/fengsh998/article/details/35783341 转载请注明出处 假设觉得文章对你有所帮助,请通过留言 ...

  4. [ACM] POJ 2154 Color (Polya计数优化,欧拉函数)

    Color Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7630   Accepted: 2507 Description ...

  5. Autodesk 举办的 Revit 2015 二次开发速成( 1.5 天),教室培训, 地点武汉

    2014年8月26日9:00 – 17:00 2014年8月27日9:00 – 12:00 培训地点: Ø 湖北工业大学 实训楼605教室 Ø 地址:武汉市武昌区南湖李家墩一村一号 Ø 交通路线说明: ...

  6. MyEclipse改动内存大小

    方式一网上说的(没有測试过): 找到MyEclipse的安装文件夹,一般假设不改动的话默觉得C:\MyEclipse10.1\Genuitec\MyEclipse 10.1有一个myeclipse.i ...

  7. C4

    #include <stdio.h> int main(int argc, const char * argv[]) { // int 占用4个字节 double 占用8个字节 // 只是 ...

  8. 0x17 二叉堆

    优先队列太好用了手写啥呀 poj1456 经过贪心专题的洗礼以后这题根本就不叫题啊...按时间大到小排每次取最大就好 #include<cstdio> #include<iostre ...

  9. Authrize特性登录验证

  10. JS实现掷骰子

    JS实现掷骰子 实现方法: 方法一:通过background-position.background-image.backg-repeat三个属性以及jquery animate()方法改变背景骰子图 ...