使用情景如下:

在访问 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的更多相关文章

  1. Nginx隐藏index.php和配置vhost

    nginx启动命令 启动:nginx停止:nginx -s stop退出:nginx -s quit重启:nginx -s reopen重新加载:nginx -s reload平滑启动:kill -H ...

  2. nginx 隐藏 index.php 和 开启 pathinfo 模式的配置

    nginx 通过 location 的规则匹配将 php 转发给 php-fpm 处理后获取结果然后返回给客户端,转发模式可以通过 unix sock 或 tcp socket 方式.百度了好多文章我 ...

  3. nginx 隐藏index.php 并开启rewrite日志调试(apache也有)

    开启rewrite 日志 error_log       /data/log/nginx/error.log notice; 位于最外层,大约在文件的前几行 再在http{}括号里增加一行:rewri ...

  4. TP5框架 nginx服务器 配置域名 隐藏index.php

    server { listen ; #server_name localhost; server_name hhy.com;/**这里写自己的域名*/ #charset koi8-r; #access ...

  5. lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php

    tp5 url 线上访问 在nginx 上 出现404错误 那是因为pathinfo没有被支持 修改如下:找到   /usr/local/nginx/config/vhost/项目名.config s ...

  6. nginx服务器绑定多个域名、支持pathinfo路由、隐藏index.php入口文件

    这篇文章仅仅是操作,解释说明部分待更新. 1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf) [root@xxx ~]# find / -name nginx. ...

  7. nginx配置隐藏index.php

    Nginx 服务器隐藏 index.php 配置   location / { try_files $uri $uri/ /index.php?$query_string; }   nginx配置中t ...

  8. nginx 环境 thinkphp 隐藏index.php

    tp官网已经写了 http://doc.thinkphp.cn/manual/hidden_index.html 不生效 重启nginx .问题依旧 kill掉nginx进程  再启动 贴段自己的配置 ...

  9. Nginx配置PATHINFO隐藏index.php

    1.网络来源:http://www.shouce.ren/post/view/id/1529 server {      listen       80;     default_type text/ ...

随机推荐

  1. poj 2175 费用流消圈

    题意抽象出来就是给了一个费用流的残存网络,判断该方案是不是最优方案,如果不是,还要求给出一个更优方案. 在给定残存网络上检查是否存在负环即可判断是否最优. 沿负环增广一轮即可得到更优方案. 考虑到制作 ...

  2. Django之模型层-了解ORM

    ORM(对象-关系-映射)简单使用 ORM实现了数据模型与数据库的解耦合,即数据模型的设计不需要指定特定的数据库,通过python代码可以直接对数据库实现增删改查 MySQL语法 #sql中的表 #创 ...

  3. 深入浅出Node.js---Connect模块解析 。转载

    文章地址:https://blog.csdn.net/zhangyuan19880606/article/details/51509205 1 Connect模块背景 Node.js的愿望是成为一个能 ...

  4. 使用terraform-provider-s3 操作minio

    尽管默认官方提供了s3 的操作,但是对于开源minio 无法支持,更多的是aws 的s3,社区提供了一个通用 s3 操作的provider(基于minio 的sdk) 环境准备 docker-comp ...

  5. 移除元素(remove,remove_if...unique...)

    remove 因为本算法作用的是iterator,所以并不会改变Container大小,会返回一个新的iterator new_last,是的first到new_last中的元素都不等于value,左 ...

  6. .Net培训班课程体系

    .Net培训 第一部分:.Net基础 .Net基础:数据类型.变量.运算符.分支结构.循环结构.方法.反编译器.递归.递归算法的非递归优化: 面向对象:异常.封装继承多态.单例模式.装饰者设计模式.t ...

  7. H5公共样式,用于所有H5开发页面

    @charset "UTF-8"; /* H5公共样式,用于所有H5开发页面*/ html { font-family: "Microsoft Yahei", ...

  8. vue-cli、create-react-app 项目如何查看打包分析?

    vue-cli.create-react-app 项目如何查看打包分析? 项目 如何查看打包分析 vue-cli 创建的项目 已经集成 webpack-bundle-analyzer,运行npm ru ...

  9. re正则匹配使用

    print(result.span()) #输入字符串的范围 如果在匹配语句中有括号,group(1)就是提取第一个括号的内容,以此类推. 扩展思考:如果要从文本中匹配出目标字符串可以使用括号加gro ...

  10. Scrapy 爬取BOSS直聘关于Python招聘岗位

    年前的时候想看下招聘Python的岗位有多少,当时考虑目前比较流行的招聘网站就属于boss直聘,所以使用Scrapy来爬取下boss直聘的Python岗位. 1.首先我们创建一个Scrapy 工程 s ...