开启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. HTTP中的URL长度限制

    首先,其实http 1.1 协议中对url的长度是不受限制的,协议原文: The HTTP protocol does not place any a priori limit on the leng ...

  2. 【Foreign】旅行路线 [倍增]

    旅行路线 Time Limit: 20 Sec  Memory Limit: 256 MB Description Input Output 仅一行一个整数表示答案. Sample Input 3 2 ...

  3. 【LA3461】Leonardo的笔记本

    白书例题. #include<bits/stdc++.h> using namespace std; ],vis[],cnt[]; inline int read(){ ,x=;char ...

  4. 【bzoj2242】计算器

    #include<bits/stdc++.h> #define inf 1000000000 using namespace std; typedef long long ll; ?a:g ...

  5. [ 手记 ] Oracle 11g安装过程

    安装环境:    操作系统:Centos6.4 Desktop    主机名:oracle    内存:2G    安装前准备:    修改主机名: [root@oracle ~]# vim /etc ...

  6. 【 Nginx 】proxy_cache 模块的使用记录

    部署环境:nginx + tomcat  同一台服务器. 通过nginx反向代理tomcat. 配置如下: user www www; worker_processes auto; error_log ...

  7. 新手学习selenium路线图(老司机亲手绘制)-学前篇【转载】

    前言: 本来这篇是只在微信公众号(yoyoketang)上发布的,最近一搜,发现本很多人copy(copy公众号的,图片是加载不出来的)了,还没注明出处,不想多说什么,博客上也同步更新这篇吧! 最近群 ...

  8. java 获取当前系统时间

    Java的Date获取时间函数都是deprecated 可以使用: https://stackoverflow.com/questions/5175728/how-to-get-the-current ...

  9. 使用 gulp 编译 Sass

    无论是 node-sass 还是 ruby-sass 使用 npm 安装都非常的慢,甚至会装不上.及其不利于团队协作.建议使用 less 作为 css 预处理器. 如果因为 less 不支持自定义函数 ...

  10. 最快的序列化组件protobuf的.net版本protobuf.net

    Protobuf是google开源的一个项目,用户数据序列化反序列化,google声称google的数据通信都是用该序列化方法.它比xml格式要少的多,甚至比二进制数据格式也小的多.     Prot ...