V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
d754903977
V2EX  ›  问与答

wordpress 静态化后的伪静态规则

  •  1
     
  •   d754903977 · 2017-02-03 22:49:54 +08:00 · 1111 次点击
    这是一个创建于 2654 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Wordpress 静态化后,页面后面加多少个 /甚至一堆乱七八糟的都可以访问...

    我用的 WP Super Cache ,求个相关的规则...

    其他的静态化插件也是这样,像异次元 http://www.iplaysoft.com/lineageos.html/12121

    目前用的规则: if ( $request_uri ~ '^/index.php$') { rewrite ^ $scheme://$host/ permanent; break; } 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; } if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") { set $qs 0; set $supercache_uri $document_uri; } 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; } if (-f $document_root$supercache_file) { #rewrite ^(.*)$ $supercache_file break; rewrite ^ $supercache_file last; } if (!-e $request_filename) { rewrite . /index.php last; } }

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1764 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:48 · PVG 00:48 · LAX 09:48 · JFK 12:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.