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/ ...
随机推荐
- [LeetCode&Python] Problem 705. Design HashSet
Design a HashSet without using any built-in hash table libraries. To be specific, your design should ...
- Readability Assessment for Text Simplification -paper
https://pdfs.semanticscholar.org/e43a/3c3c032cf3c70875c4193f8f8818531857b2.pdf 1.introduction在Brazil ...
- lesson2-cnn-fastai
%mkdir的做法glob('.jpg')np.random.permutation(图片)np.random.rename(,)#save_array:utils中,连接每个btch得到的数组#ke ...
- 11月15Sprint计划会议及内容·
今天对整体设计做了明确的规划 工作分配: 1规划 2规则制定 3窗体设计 4模型设计 5代码编写 6美化 7产品交付 8后期宣传 王超群前四项 吕浩宇后四项
- 斐波那契 - pythoon实现
def fn_1(n): if n == 0 : return n elif n == 1 : return n else: a = [0,1] for i in range(2,n): a.appe ...
- Bellman-Ford的队列优化
Bellman-Ford算法在每实施依次松弛后,就会有一些顶点已经求得最短路,此后这些顶点的最短路的估计值就会一直不变,不再收后续松弛操作的影响,但是每次还要判断是否需要松弛,这就浪费时间了. 从上面 ...
- 【liunx】时间处理函数
一.脚本示例 [mylinuxaccount@linux01 ~]$ date +%Y%m%d 20171224 [mylinuxaccount@linux01 ~]$ date +%F 2017-1 ...
- Hive GenericUDF2
再来看一个分数统计的小例子. 在Hive中存在如下一张表: hive> describe tb_test2; OK name string score_list array<map ...
- 【VBA研究】VBA自己定义函数參数类型不符的错误
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/iamlaosong/article/details/36871769 作者:iamlaosong 1 ...
- 原生js实现的瀑布流布局
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...