tp 在Nginx上各种404
对于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
- location ~ \.php { #去掉$
- root H:/PHPServer/WWW; 笔者这里默认是 html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
- fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
这样就实现了nginx 支持pathInfo
2、实现完全支持tp5 隐藏index.PHP 以及支持 pathinfo 栗子:
- server {
- listen 8082;
- server_name localhost;
- charset utf-8;
- access_log logs/host.access.log main;
- root /usr/local/nginx/html/thinkphp/public;
- index index.html index.htm index.php;
- location / {
- if (!-e $request_filename) {
- rewrite ^(.*)$ /index.php?s=$1 last;
- break;
- }
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fastcgi_params;
- set $real_script_name $fastcgi_script_name;
- if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
- set $real_script_name $1;
- set $path_info $2;
- }
- fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
- fastcgi_param SCRIPT_NAME $real_script_name;
- fastcgi_param PATH_INFO $path_info;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
- expires 30d;
- access_log off;
- }
- location ~ .*\.(js|css)?$ {
- expires 7d;
- access_log off;
- }
- }
tp 在Nginx上各种404的更多相关文章
- tp5 url 线上访问 在nginx 上 出现404错误,解决办法(1.80nginx 配置 pathInfo)
对于ThinkPHP的URL访问路劲如:http://域名/index.php/Index/BlogTest/read,原先的Nginx的是不支持的pathinfo路劲的,导致你在thinkPHP ...
- 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 : . ...
- nginx上如何支持.htaccess伪静态转向
我们知道在apache上有一个常用的功能.htaccess转向,只要apache编译的时候指明支持rewrite模块就可以了. 但是换到nginx上方法会有一点不一样,网上很多人说把.htaccess ...
- 在nginx上部署vue项目(history模式);
在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...
- nginx上支持.htaccess伪静态的配置实例
本文介绍下,在nginx上配置.htaccess伪静态的方法,有需要的朋友参考下吧. 在apache上.htaccess转向,只要apache编译的时候指明支持rewrite模块即可. 但是换到ngi ...
- apache上.htaccess转向nginx上配置.htaccess伪静态规则
nginx上配置.htaccess伪静态规则 在apache上.htaccess转向,只要apache编译的时候指明支持rewrite模块即可. 但是换到nginx上方法会有不同,有人说把.htacc ...
- 在Nginx上部署ThinkPHP,解决Pathinfo问题
在Nginx上部署ThinkPHP,解决Pathinfo问题 事实上.要解决nginx不支持pathinfo的问题.有两个解决思路,一是不使用pathinfo模式,二是改动nginx的配置文件,使它支 ...
- Nginx之伪404( root与alias )
目录 一.现象 二.root与alias的区别 三.建议 四.写在最后 一.现象 人类善于伪装,机器某些时候也善于伪装:Nginx请求看到404,第一反应就是文件不存在:但我们去检查的时候,它就正 ...
- nginx上部署python web
nginx上部署python web http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
随机推荐
- hibernate框架总结
实体类编写规则1 实体类里面属性私有的 2 私有属性使用公开的set和get方法操作 3 要求实体类有属性作为唯一值(一般使用id值) 4 实体类属性建议不使用基本数据类型,使用基本数据类型对应的包装 ...
- NetOps Defined
https://www.logzilla.net/2017/06/20/the-network-operations-top-5.html
- mengento 数据库模型
- ZOJ 3203
很简单的一题,注意墙上的影子是放大就行.用三分. #include <iostream> #include <cstdio> #include <cstring> ...
- 24岁菜鸟,能一个人撑起App开发吗
"疲惫吾心.怎样躲藏.四处荒芜,怎话忧伤?"临近中秋,看到艾瑞斯的QQ签名,无尽的伤感.这个年仅24的青年.连续3年没有回家了,近期一个月总是失眠,没有家人的陪伴,就连女朋友 ...
- Geeks - Range Minimum Query RMQ范围最小值查询
使用线段树预处理.能够使得查询RMQ时间效率在O(lgn). 线段树是记录某范围内的最小值. 标准的线段树应用. Geeks上仅仅有两道线段树的题目了.并且没有讲到pushUp和pushDown操作. ...
- kentico中提示Message: An invalid SQL query was used.
在调用CMSAbstractWebPart类的GetValue方法的时候出错. namespace CMS.PortalEngine.Web.UI{ /// <summary> /// B ...
- hdoj--1251--统计难题(字典树)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others) Total Subm ...
- SQL语句之Insert
插入常见的3种形式: 单条插入, 批量插入, 返回刚插入行的id http://www.cnblogs.com/yezhenhan/archive/2011/08/17/2142948.html
- sql语句获取本周、本月、本年数据
本周:select * from table where datediff(week,C_CALLTIME,getdate())=0 --C_CALLTIME 为日期字段本月:select * ...