关于nginx隐藏index.php入口文件注意事项
最近项目用的是nginx服务,apache怎么隐藏入口不赘述,官方文档有介绍,Nginx隐藏官方文档这样说的:

实践中,这样是不对的,应该在网站对应的vhost.conf中配置:
server {
listen 80;
server_name test.aaa.com;
root "D:/phpstudy_pro/WWW/test.aaa.com/public";
location / {
index index.php index.html error/index.html;
error_page 400 /error/400.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
error_page 506 /error/506.html;
error_page 507 /error/507.html;
error_page 509 /error/509.html;
error_page 510 /error/510.html;
autoindex off;
if (!-e $request_filename){
rewrite ^(.*)$
/index.php?s=/$1 last;
}
}
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;
}
}
重点是加上这一行:
if (!-e $request_filename){
rewrite ^(.*)$
/index.php?s=/$1 last;
}
关于nginx隐藏index.php入口文件注意事项的更多相关文章
- nginx服务器绑定多个域名、支持pathinfo路由、隐藏index.php入口文件
这篇文章仅仅是操作,解释说明部分待更新. 1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf) [root@xxx ~]# find / -name nginx. ...
- thinkphp5.0如何隐藏index.php入口文件
隐藏入口文件 public/index.php 同级的.htaccess文件 [ Apache ] 方法1: <IfModule mod_rewrite.c> Options +Follo ...
- CI 框架 隐藏index.php 入口文件 和 设置访问application下子目录
1.隐藏根目录下 index.php, 在根目录下创建 .htaccess文件 内容如下: <IfModule mod_rewrite.c> RewriteEngine on Rewrit ...
- tp5无法隐藏index.php入口文件
一: 官方文件: <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine on Rewrite ...
- index.php入口文件至根目录
登录|注册 咖啡如同生活的专栏 从不羡慕别人的优秀,因为相信自己也可以优秀. 闲下来时看看书,书本里的故事,总有你学到的人生. 目录视图 摘要视图 订阅 异步赠书:9月重磅 ...
- 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
使用情景如下: 在访问 http://php.cc/Att/AttList 的时候.跳转到 http://php.cc/index.php/Att/AttList : 也就是开启重写功能: 在ngin ...
- ThinkPHP中通过URL重写隐藏应用的入口文件index.php的相关服务器的配置
[ Apache ] 将httpd.conf配置文件中mod_rewrite.so所在行前面的‘#’去掉 AllowOverride None 将None改为 All 效果图
- nginx 隐藏index.php 并开启rewrite日志调试(apache也有)
开启rewrite 日志 error_log /data/log/nginx/error.log notice; 位于最外层,大约在文件的前几行 再在http{}括号里增加一行:rewri ...
随机推荐
- C-07\字符串的输入输出及常用操作函数
一.算法优化: 减少分支优化 // 求绝对值 int MyAbs(int n) { if (n < 0) { n = ~n + 1; } return n; } // 优化 int MyAbs( ...
- springboot多模块controller访问的问题
参考 https://blog.csdn.net/qq_25091649/article/details/88429512 情况一:在主类直接写controller接口,能够访问到 @SpringBo ...
- 树莓派4B—LCD触摸屏和硬件串口配置
1.LCD触摸屏直接下载官网驱动,这里选用的是3.5寸显示屏,解压后直接运行 sudo ./LCD35-show 然后重启. 注意:一定要先安装LCD驱动,因为安装驱动会修改/boot/config. ...
- python_添加中文编码和脚本
#!/usr/bin/env python 根据环境设置寻找python路径,必须放在第一行 # coding=utf-8 添加中文编码
- 一段简单的对TXT文件的操作代码
1 string txt = @"C:\DetectFolder\IPV4地址.txt"; 2 string path = ""; 3 4 if (File.E ...
- JavaScript是怎样实现继承的?
一.是什么 继承(inheritance)是面向对象软件技术当中的一个概念. 如果一个类别B"继承自"另一个类别A,就把这个B称为"A的子类",而把A称为&qu ...
- concurrent-map 和 sync.Map,我该选择哪个?
concurrent-map 和 sync.Map,我该选择哪个? 官方的map并不是线程安全的,如果我们在多线程中并发对一个map进行读写操作,是会引发panic的.解决方案除了使用锁来对map进行 ...
- 关于Promise.all()的理解
本篇笔记是抄的别人的,目的只是为了日后有用到时有个参考,原文地址是https://www.jianshu.com/p/7e60fc1be1b2 一.Pomise.all的使用 Promise.all可 ...
- 自己从零写操作系统GrapeOS系列教程——4.GrapeOS开发环境介绍
1. 开发环境简介 为了减少开发过程中不必要的麻烦,希望大家的开发环境尽量与我的保持一致. 我的开发环境如下: Windows10电脑一台 Visual Studio Code(最好是最新版) Vir ...
- label勾选问题,checkbox
<input id="overck_21" data-role="none" name="check" class="reg ...