Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
来源:互联网 发布:淘宝的内部优惠微信号 编辑:程序博客网 时间:2024/06/06 05:58
thinkphp5.0标准的 URL 访问格式
http://serverName/index.php/模块/控制器/操作
浏览器访问出现404
nginx配置
server { listen 84; server_name localhost; root /usr/share/nginx/html; index index.php; access_log /var/log/nginx/html-access.log; error_log /var/log/nginx/html-error.log; location / { try_files $uri $uri/ /index.php?$args =404; #try_files $uri$args $uri$args/ index.php; } location ~ .*\.(php|php7.0)?$ { #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; include fastcgi_params; } location ~ /\.(ht|svn|git) { deny all; }}
更改后
server { listen 84; server_name localhost; access_log /var/log/nginx/html-access.log; error_log /var/log/nginx/html-error.log; #root是下面设计到文件路径的根目录 root /usr/share/nginx/html; index index.html index.php; #定义变量 set $root /usr/share/nginx/html; #匹配url中server_name之后的部分 location /tp5/public/ { #重写url 为了隐藏tp5中的index.php if ( !-e $request_filename) { #将url中server_name之后的部分与 /tp5/public/* 匹配 如果匹配则改写URl为/tp5/public/index.php/* rewrite ^/tp5/public/(.*)$ /tp5/public/index.php/$1 last; break; } } #pathinfo配置 使支持tp5的标准url location ~ .+\.php($|/) { fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; include fastcgi_params; }}
web目录
/usr/share/nginx/html
项目结构
阅读全文
0 0
- Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
- nginx重写url隐藏index.php
- thinkphp5 隐藏index.php方法
- Nginx 服务器隐藏 index.php 配置
- nginx 隐藏index.php
- thinkphp5.0隐藏index.php入口文件
- thinkphp5 去掉url里的index.php
- YII2 URL美化以及隐藏入口文件index.php
- yii框架 隐藏index.php 以及美化URL
- nginx多站点配置,以及隐藏index.php
- Yii URL隐藏index.php
- 关于ThinkPHP5.0在Apache下隐藏index.php报错的问题
- nginx 404页面处理以及pathInfo和隐藏index.php总述
- CI在nginx环境下去掉url中的index.php
- ThinkPHP 在nginx环境下去掉URL中的index.php
- thinkphp nginx实现url pathinfo模式并隐藏url index.php
- thinkphp5在SAE上部署隐藏index.php
- thinkphp5 IIS7.5 隐藏index.php的方法
- forEach和$.each()以及$().each()的用法
- [docker]docker命令docker run的小结
- 工厂设计模式
- 如何在基于tensorflow的深度学习框架keras中指定GPU
- C++中两个类相互引用的解决办法
- Nginx服务器下ThinkPHP5访问出现404以及URL隐藏index.php
- 负载均衡以及四层和七层负载均衡的区别
- 正则表达式-匹配IP、域名
- Java数据类型
- CodeForces
- 64位centos7 编译 32位文件出错
- frame、bounds与center属性
- 取近似值
- spark 2.1 reduce