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
随机推荐
- InitializingBean 和 DisposableBean 指定初始化和销毁方法
通过实现 InitializingBean 和 DisposableBean 接口,也可以指定 bean 的初始化和销毁方法 二.Student 类 public class Student impl ...
- LightOJ1214 Large Division
/* LightOJ1214 Large Division http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1 ...
- xml解析之----DOM解析
DOM模型(documentobject model) •DOM解析器在解析XML文档时,会把文档中的全部元素.依照其出现的层次关系.解析成一个个Node对象(节点). •在dom中.节点之间关系例如 ...
- BAT常问问题总结以及回答(java基础回答一)
java 基础 八种基本数据类型的大小,以及他们的封装类 答:八种数据类型分别是byte(1字节)-128~127.short(2字节)-32768~32767.char(2字节).int(4字节) ...
- 为data盘加入磁盘(asm external)
1.创建盘,并两个节点皆能够訪问. 2.检查集群状态 [grid@rac1 ~]$ crsctl status res -t ------------------------------------- ...
- C4
#include <stdio.h> int main(int argc, const char * argv[]) { // int 占用4个字节 double 占用8个字节 // 只是 ...
- [POJ 1316] 树上的询问
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1316 [算法] 点分治 由于边权较大,笔者在计算时使用了STL-set 注意当询问为 ...
- 10. Regular Expression Matching[H]正则表达式匹配
题目 Given an input string(s) and a pattern(p), implement regular expression matching with support for ...
- Xcode的一些控制台命令
命令 解释 break NUM 在指定的行上设置断点 bt 显示所有的调用栈帧,该命令可用来显示函数的调用顺序 clear 删除设置在特定源文件.特定行上的断点,其用法为:clear FILENAME ...
- SQL语句之Insert
插入常见的3种形式: 单条插入, 批量插入, 返回刚插入行的id http://www.cnblogs.com/yezhenhan/archive/2011/08/17/2142948.html