php版本5.6 伪静态规则直接用后台的
wp博客搬家出现 的情况,把页面缓存进内存就好了,先安装Memcached(宝塔就能够安装,并且php配置里面也能安装)
在网站根目录下的 wp-config.php 中添加如下语句开启缓存:
/** 激活Memcached */
define(‘ENABLE_CACHE’, true);
/** 激活Batcache */
define(‘WP_CACHE’, true);
做到以上两点之后,我们需要对站点的 Nginx 配置文件中添加以下配置,重启 Nginx。
下面这段代码放在配置文件最后的一个括号前的
location ~ / {
error_page 404 405 = @nocache;
if ( $query_string ) {
return 405;
}
if ( $request_method = POST ) {
return 405;
}
if ( $request_uri ~ “/wp-” ) {
return 405;
}
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
return 405;
}
default_type text/html;
add_header X-Powered-By Cachify;
set $memcached_key $host$uri;
memcached_pass localhost:11211;
}
location @nocache {
try_files $uri $uri/ /index.php?$args;
}
然后在wordpress插件里搜索 Cachify 下载安装并启用。我的配置如下:内存 2000 html+js
评论前必须登录!
注册