wordpress在nginx环境下启用URL重写
2017-05-04 21:57
211 查看
在nginx配置文件增加以下代码
针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉
location / { # 如果请求的文件已存在,直接返回 if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; set $supercache 1; set $ihttp_host ''; if ($request_method = POST) { set $supercache 0; } # 仅在访问文章永久链接时使用静态文件,请求中带参数则不使用静态缓存 set $qs 0; if ($query_string) { set $qs 1; } # 不过从 twitter, facebook, feedburner 链接点过来的,总是带参数,这些访问仍然可以使用静态文件 if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } #deactivate on high load if ($qs = 1) { set $supercache 0; } # 针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉 if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } # 支持移动设备,访问移动版本的网页缓存 if ($http_user_agent ~* '(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)') { set $ihttp_host '-mobile'; } # 指定静态缓存文件的路径 if ($supercache = 0) { set $supercache_uri ''; } if ($supercache_uri ~ ^(.+)$) { set $supercache_file /wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html; } # 只有当缓存文件存在时,才进行 rewrite if (-f $document_root$supercache_file) { #rewrite ^(.*)$ $supercache_file break; rewrite ^ $supercache_file last; } # 所有其他请求,转给 wordpress 处理 if (!-e $request_filename) { rewrite . /index.php last; }
针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache 0; } }
相关文章推荐
- 如何在nginx环境中启用php的pathinfo URL模式[修正]
- 如何在安装的lnmp一键环境包(nginx)启用pathinfo URL模式
- nginx 常用的 URL 重写方法
- nginx常用的 URL 重写方法
- nginx 常用 URL 重写的方法
- ThinkPHP 在nginx环境下去掉URL中的index.php
- nginx服务器中url重写rewrite参数和例子
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress
- Nginx常用的 URL 重写方法
- 用于iis中的wordpress,wp的url重写
- nginx 常用的 URL 重写方法
- 如何正确配置Nginx+PHP及正确的nginx URL重写
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- codeigniter 在 nginx 下的 pathinfo url 重写配置
- nginx 常用的 URL 重写方法(转)
- wamp环境下url无法重写和出现提示PHP Warning: PHP Startup: in Unknown on line 0
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress、Discuz
- Nginx、PCRE和中文URL(UTF8编码)rewrite路径重写匹配问题
- Nginx 一些常用的URL 重写方法
- Ecshop url重写 apache环境配置伪静态