开启rewrite 日志

error_log       /data/log/nginx/error.log notice;

位于最外层,大约在文件的前几行

再在http{}括号里增加一行:rewrite_log on;

重写的日志将写入/data/log/nginx/error.log

关键代码

在http{ server{ location {#代码处} }}里写代码

location / {

  if ( !-e $request_filename ) {

    rewrite ^/(.*)$ /index.php?s=$1 last;

    break;

  }

}

若有ask目录则:

location /ask/ {

  if ( !-e $request_filename ) {

    rewrite ^/(.*)$ /ask/index.php?s=$1 last;

    break;

  }

}

location的顺序与执行顺序无关

php代码获取$_GET['s']代码

nginx.conf格式

...

events{

}

http{

  upstream xxx{

  }

  server {

    location {

      if () {

        }
    }
  } }

apache 的重写规则

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index\.php?s=$ [QSA,PT,L]
#QSA意味着,如果有一个与原始URL查询字符串传递,它将被附加到重写(olle?p=1将被重写为index.php?url=olle&p=。
#L意味着如果规则匹配,不处理任何更多RewriteRules下面这一个。
#PT(pass through to next handler) 传递给下一个处理

nginx 隐藏index.php 并开启rewrite日志调试(apache也有)的更多相关文章

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

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

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

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

  3. nginx 隐藏 index.php

    使用情景如下: 在访问 http://php.cc/Att/AttList 的时候.跳转到 http://php.cc/index.php/Att/AttList : 也就是开启重写功能: 在ngin ...

  4. MyBatis 开启 Log4j 日志调试信息开关

    Log4j 是什么 Log4j 是由 Apache 提供的开源日志框架,用于帮助用户处理日志信息. Log4j 能将日志信息分级打印和存储,而且提供了日志不同的存储方式,我们可以将日志发送到控制台,或 ...

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

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

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

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

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

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

  8. nginx 环境 thinkphp 隐藏index.php

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

  9. Nginx如何隐藏index.html

    我要隐藏目录下的index.html,修改Nginux配置如下: 1.修改文档顺序 index  index.html index.php 2.开启目录流量 在server或location 段里添加 ...

随机推荐

  1. org.apache.http.conn.HttpHostConnectException: Connection to xxx refused.

    if you are using emulator to run your app for local server. mention the local ip as 10.0.2.2 and hav ...

  2. hibernate连接oracle数据库

    前言:以下所有的操作都是基于你已经成功安装了oracle数据库并且java的开发环境正常的情况下进行的. 如果没有完善请先配置基础环境. 第一步:配置需要的环境(下载并导入需要的包). 下载链接:ht ...

  3. 使用FindBugs-IDEA插件找到代码中潜在的问题

    另一篇使用文档,参照:https://www.cnblogs.com/huaxingtianxia/p/6703315.html 我们通常都会在APP上线之后,发现各种错误,尤其是空指针异常,这些错误 ...

  4. 【BZOJ1468】Tree [点分治]

    Tree Time Limit: 10 Sec  Memory Limit: 64 MB[Submit][Status][Discuss] Description 给你一棵TREE,以及这棵树上边的距 ...

  5. noip2016 提高组

    T1 玩具谜题 题目传送门 这道题直接模拟就好了哇 233 #include<cstdio> #include<cstring> #include<algorithm&g ...

  6. bzoj 1088 DP

    我们可以用w[i][s]来表示到第i位的方案,s代表第i位和第i+1位是否有雷的二进制串,那么我们就可以根据每一位的雷的数量转移了. /******************************** ...

  7. 【 Keepalived 】Nginx or Http 主-主模式

    上一篇:[ Keepalived ]Nginx or Http 主-备模式 在此基础上进行修改并实现 Keepalived主-主模式 首先,需要理解的是:主-备模式是一个VIP在工作,主-主模式则需要 ...

  8. [设计模式-行为型]访问者模式(Vistor)

    一句话 表示一个作用于某对象结构中的各元素的操作.它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作. 概括

  9. hdu 1115(多边形重心问题)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  10. AC日记——[SCOI2012]喵星球上的点名 bzoj 2754

    2754 思路: AC自动机暴力处理匹配: 强大的ac自动机,强大的fail树,强大的map,强大的vector,强大的指针: 代码: #include <map> #include &l ...