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/ ...
随机推荐
- WPA2 Key Reinstallation 漏洞
漏洞形成: 必要条件1:WPA2 协议存在一个消息重放漏洞,导致多组相同数据被使用了相同的密钥加密. ciphertext = plaintext xor AES(key, IV||counter) ...
- [c++]base64编解码 and image
//½«Í¼ÏñתΪbase64¸ñʽ vector<uchar> vecImg; //Mat ͼƬÊý¾Ýת»»Îªvector<uchar> vector< ...
- 通过web.config来自定义output caching缓存
我们服务器有开启缓存功能, 缓存功能可以减少您访问网站时候网站在服务器里面的编译时间, 大大加快您网站的访问速度, 如果您需要对您网站进行频繁更新的话, 您可以考虑暂时将缓存时间减少,或者暂时关闭缓存 ...
- SQLI DUMB SERIES-2
less2 同Less1相同,存在注入点 输入 ?id=1' 说明我们输入的数据被原封不动的带入了,无需要在1后面加单引号 (1)爆字段 ?id=1 order by 4 字段为3. (2)用unio ...
- JSM的topic和queue的区别
在JMS(Java消息服务)中,Topic实现publish和subscribe语义.一条消息被publish时,它将发到所有感兴趣的订阅者,所以零到多个 subscriber(电脑词汇中解释为“用户 ...
- Http&Tomcat
一张图 tomcat的安装和启用: Tomcat有安装版和解压版(绿色版)安装版以.exe形式的安装包,双击安装到我们的电脑上,用的比较少.解压版,即绿色版,解压后直接使用,用的比较多 bin:脚本目 ...
- python可变类型和不可变类型
原文地址:http://www.cnblogs.com/huamingao/p/5809936.html 可变类型 Vs 不可变类型 可变类型(mutable):列表,字典 不可变类型(unmutab ...
- yum源更换为本地光盘
下面来示范一下如何使用光盘文件配置yum库.注意:一定要把/etc/yum.repos.d里的其他文件移到其他地方,否则会报错 进入到/etc/yum.repos.d目录中后创建Yum配置文件: [r ...
- JQuery左右切换实现
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Using Elixir Dynamic Supervisors
转自: https://blog.smartlogic.io/elixir-dynamic-supervisors/ I have been working on my side project Gr ...