nginx 隐藏index.php 并开启rewrite日志调试

开启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 () {

        }
    }
  }

}
时间: 2024-08-03 15:34:17

nginx 隐藏index.php 并开启rewrite日志调试的相关文章

nginx 隐藏index.php 路径path化

server { listen       80 default; server_name  _; index index.html index.htm index.php; #root /alidata/www/default; root /alidata/www/sandbox_pro/sandbox; #rewrite ^/box/list   /index.php?r=box/list ; #rewrite ^/(.*)$   /index.php?r=$1 ; if ( -f  $re

nginx 隐藏index.html

公司原有的需求是敲域名后自动跳转到index.html页面,其它的动态页面全部转发到后面tomcat处进行解析,并且浏览器的地址也添加了index.html,如: 访问:www.test.com 敲回车后浏览器中自动跳转致: www.test.com/index.html 今天公司提出一个新的需求,如: 访问:www.test.com 敲回车后浏览器中url不变,配置如下: upstream index { server 123.159.147.369:7069  weight=20 max_f

【铜】第135篇 一对一视频录制(二)及必填项红色星标及隐藏index.php及必选项不能为空 周一

关键词:一对一视频录制, 必填项红色星标, 隐藏index.php, 必选项不能为空 一.一对一视频录制 1.1 需要做的 二.我的网站 2.1 必填项红色星标 代码如下: <spanstyle="color:red;">*</span> 效果如下: 2.2 隐藏index.php 1)开启mod_rewrite.so LoadModule rewrite_modulemodules/mod_rewrite.so 注:去掉前面的#,重启apache即可. 2)如

nginx 404页面处理以及pathInfo和隐藏index.php总述

今天开发公司官网:http://www.zstime.com/,遇到一个问题,如何在nginx下设置pathInfo以及如何隐藏index.php 这里分别来讲解一下: 一.隐藏index.php 隐藏index.php需要修改nginx的配置文件,如果你是使用vhost的,需要修改如conf/vhost/你的文件名.conf 文件,整个文件如下 server { listen 80; server_name www.zstime.com; index index index.html inde

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

这篇文章仅仅是操作,解释说明部分待更新. 1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf) [[email protected] ~]# find / -name nginx.conf [[email protected] ~]# vim /etc/nginx/nginx.conf nginx.conf配置文件的大致结构: ... http{ server{ ... #一个server结构可以对应一个域名 } include vhosts/*.conf

Nginx配置PATHINFO隐藏index.php

1.网络来源:http://www.shouce.ren/post/view/id/1529 server {      listen       80;     default_type text/plain;     root /var/www/html;     index index.php index.htm index.html; #隐藏index.php     location / {           if (!-e $request_filename) {         

nginx 开启rewrite thinkcmf

server{ ... 省略 location / { index index.php index.html index.htm; #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则 if (!-e $request_filename) { #地址作为将参数rewrite到index.php上. rewrite ^/(.*)$ /index.php?s=$1; #若是子目录则使用下面这句,将subdir改成目录名称即可. #rewrite ^/subdir/(.*)$ /subdir/

Nginx教程(四) Location配置与ReWrite语法

1 Location语法规则 1.1 Location规则 语法规则: location [=|~|~*|^~] /uri/ {- } 首先匹配 =,其次匹配^~,其次是按文件中顺序的正则匹配,最后是交给 /通用匹配.当有匹配成功时候,停止匹配,按当前匹配规则处理请求. 符号 含义 = = 开头表示精确匹配 ^~ ^~开头表示uri以某个常规字符串开头,理解为匹配 url路径即可.nginx不对url做编码,因此请求为/static/20%/aa,可以被规则^~ /static/ /aa匹配到(

Nginx配置请求转发location及rewrite规则

一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location / { # 因为所有的地址都以 / 开头,所以这条规则将匹配到所有请求 # 但是正则和最长字符串会优先匹配 [ configuration B ] } location /documents/ { # 匹配任何以 /documents/ 开头的地址,匹配符合以后,还要继续往下搜索 # 只有后面的正则表达式没有匹配到时,这一条才会采用这一条 [ c