当我们从apache服务器转向Nginx服务器的时候,它们的伪静态规则就不一样了,所以你熟悉Nginx服务器的伪静态规则,自己写当然也好.不了解Nginx服务器的伪静态规则的,为方便各位站长,收集了这几个常用程序的伪静态规则,常用的程序,如 WordPress,PHPCMS,ECSHOP,SHOPEX,Discuz 7. WordPress伪静态规则 location / { index index.html index.php; if (-f $request_filename/index.h…
每次都很容易忘记Nginx的变量,下面列出来了一些常用 $remote_addr //获取客户端ip $binary_remote_addr //客户端ip(二进制) $remote_port //客户端port,如:50472 $remote_user //已经经过Auth Basic Module验证的用户名 $host //请求主机头字段,否则为服务器名称,如:blog.sakmon.com $request //用户请求信息,如:GET ?a=1&b=2 HTTP/1.1 $reques…
当我们从apache服务器转向Nginx服务器的时候,它们的伪静态规则就不一样了,所以你熟悉Nginx服务器的伪静态规则,自己写当然也好.但很多网友还是不太了解Nginx服务器的伪静态规则的,而如果你安装的是wordpress的话今天就给大家提供一个参考:   location / {  index index.html index.php;  if (-f $request_filename/index.html){   rewrite (.*) $1/index.html break; }…
nginx里使用伪静态是直接在nginx.conf 中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态. nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可.   复制代码 代码如下: server { listen ; server_name bbs.jb51.net; index index.html index.htm index.php; root /home/www/bbs; error_page /.htm; #配…
上一篇博文对nginx最常用功能的server及location的匹配规则进行了讲解,这也是nginx实现控制访问和反向代理的基础.掌握请求的匹配规则算是对nginx有了入门,但是这些往往还是不能满足实际的需求场景,例如请求url重写.重定向等等,这都需要对请求的path进行修改操作的,匹配规则是不能独自完成实际需求的,这就需要掌握nginx的另一个常用功能rewrite,下面就来说说这个常用功能. Rewrite规则 rewrite功能就是,使用nginx提供的全局变量或自己设置的变量,结合正…
目前已收集Wordpress.Wordpress二级目录.PHPCMS.ECSHOP.ShopEX.SaBlog.Discuz.Discuz X.PHPWind.Typecho.DEDECMS: WordPress: location / {index index.html index.php;if (-f $request_filename/index.html){rewrite (.*) $1/index.html break;}if (-f $request_filename/index.…
location 以 = 开头,表示精确匹配:如只匹配根目录结尾的请求,后面不能带任何字符串. 以^~ 开头,表示uri以某个常规字符串开头,如果匹配到,则不继续往下匹配.不是正则匹配 以~ 开头,表示区分大小写的正则匹配; 以~* 开头,表示不区分大小写的正则匹配 以/ 开头,通用匹配, 如果没有其它匹配,任何请求都会匹配到 **注意 location xxx {} 其中xxx与括号之间很多时候需要空格,最好都加上* 匹配顺序: (location =) > (location 完整路径) >…
1. /a/b?c=d => index.php?_a=a&_m=b&c=d 2. /xxx/detail-yyy.html => index.php?_a=xxx&_m=detail&id=yyy server { listen 80; server_name my.xh5.com; location / { root /mnt/hgfs/web/my.xueh5.com/src/; index index.html index.htm index.php;…
server { listen 80; server_name sss.cn; root "root/"; location / { index index.html index.htm index.php; if (-f $request_filename/index.html){ rewrite (.) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.) $1/index.php; } if…
网上收集的一些常用的,要用的时候就仿照一下,或直接拿来用. WordPress伪静态规则 location / { index index.html index.php; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filenam…