nginx 隐藏 index.php
使用情景如下:
在访问 http://php.cc/Att/AttList 的时候、跳转到 http://php.cc/index.php/Att/AttList ;
也就是开启重写功能;
在nginx配置文件nginx.conf中添加:
location / {
if ( !e $request_filename ) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
如果项目入口文件是在一个子目录里面,则如下:
location / {
if ( !e $request_filename ) {
rewrite ^/目录/(.*)$ /目录/index.php/$1 last;
}
}
切记:不可以出现两个location / {}、否则nginx服务器将启动不了;
我的配置文件如下:
server {
listen 80;
server_name www.abcphp.cc abcphp.cc;
root "D:/abc/php";
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?$1 last;
}
index index.html index.htm index.php;
autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
其中:
autoindex on; 是打开nginx的浏览目录的功能;
原文地址:https://mp.weixin.qq.com/s/ltd3LlZn4vpq1vxCRqSaQQ
nginx 隐藏 index.php的更多相关文章
- Nginx隐藏index.php和配置vhost
nginx启动命令 启动:nginx停止:nginx -s stop退出:nginx -s quit重启:nginx -s reopen重新加载:nginx -s reload平滑启动:kill -H ...
- nginx 隐藏 index.php 和 开启 pathinfo 模式的配置
nginx 通过 location 的规则匹配将 php 转发给 php-fpm 处理后获取结果然后返回给客户端,转发模式可以通过 unix sock 或 tcp socket 方式.百度了好多文章我 ...
- nginx 隐藏index.php 并开启rewrite日志调试(apache也有)
开启rewrite 日志 error_log /data/log/nginx/error.log notice; 位于最外层,大约在文件的前几行 再在http{}括号里增加一行:rewri ...
- TP5框架 nginx服务器 配置域名 隐藏index.php
server { listen ; #server_name localhost; server_name hhy.com;/**这里写自己的域名*/ #charset koi8-r; #access ...
- lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php
tp5 url 线上访问 在nginx 上 出现404错误 那是因为pathinfo没有被支持 修改如下:找到 /usr/local/nginx/config/vhost/项目名.config s ...
- nginx服务器绑定多个域名、支持pathinfo路由、隐藏index.php入口文件
这篇文章仅仅是操作,解释说明部分待更新. 1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf) [root@xxx ~]# find / -name nginx. ...
- nginx配置隐藏index.php
Nginx 服务器隐藏 index.php 配置 location / { try_files $uri $uri/ /index.php?$query_string; } nginx配置中t ...
- nginx 环境 thinkphp 隐藏index.php
tp官网已经写了 http://doc.thinkphp.cn/manual/hidden_index.html 不生效 重启nginx .问题依旧 kill掉nginx进程 再启动 贴段自己的配置 ...
- Nginx配置PATHINFO隐藏index.php
1.网络来源:http://www.shouce.ren/post/view/id/1529 server { listen 80; default_type text/ ...
随机推荐
- Oracle密码概要文件,密码过期时间180天修改为3天,相关用户密码是否过期
#Oracle用户密码,概要文件修改测试 #默认的用户使用概要文件,默认概要文件密码过期时间参数180天,修改为3天,对于老的用户来说,是密码过期,还是未发生改变, 对于新用户来说,新设置的密码过期时 ...
- NOI-1.1-06-空格分隔输出-体验多个输入输出
06:空格分隔输出 总时间限制: 1000ms 内存限制: 65536kB 描述 读入一个字符,一个整数,一个单精度浮点数,一个双精度浮点数,然后按顺序输出它们,并且要求在他们之间用一个空格分隔. ...
- angular-translate
angular.module('app.core', ['pascalprecht.translate']).config(['$translateProvider', '$translatePart ...
- ElasticSearch 从零到入门
摘自:https://www.cnblogs.com/keme/p/10108918.html
- webservice------UDDI SOAP WSDL 之间的关系
[ 真的是服了一些博客.....啰里啰唆的将一堆== 根本不知道讲的是什么 ... 在描述一个定义之前 (不如先通俗的讲它是干什么的)] SOAP(Simple Object Access P ...
- HDU2044:一只小蜜蜂...
题目贴不上了︿( ̄︶ ̄)︿http://acm.hdu.edu.cn/showproblem.php?pid=2044 注意数据类型,用int会超范围 #include<stdio.h> ...
- (1)什么是web框架和http协议
Django是一个web框架 web框架的本质:就是一个socket服务端 bs架构本质上就是cs架构(cs架构就是client和server):bs架构就是browser和server,本质上bro ...
- python3.x 正则表达式的应用
正则表达式是我认为比较难的一个东西,今天忽然又学到了这个,想到写下来,以后作为参考手册使用. python如果想使用python需要引用re方法,在文件开始进行引用. import re 接下来说一下 ...
- SQLite数据库下载
一:SQLite简介 SQLite是一种嵌入式数据库,它的数据库就是一个文件.体积很小,经常被集成到各种应用程序中,甚至在iOS和Android的App中都可以集成. 要操作关系数据库,首先需要连接到 ...
- skipper http router 工具
skipper 是一个http router && 反向代理服务组件,同时支持类似kubernetes 模型的ingress,由zalando 公司的团队开发 并开源,从功能上来看,可 ...