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

这个 301 重定向怎么弄?

  •  
  •   happylty · 2018-02-27 23:30:53 +08:00 · 1755 次点击
    这是一个创建于 2221 天前的主题,其中的信息可能已经有所发展或是发生改变。
    自己弄了个博客,注册了七牛存储
    我想把 http://www.yunbeta.cn/wp-content/uploads/2018/02/XXXXX.jpg
    换成 http://niu.yunbeta.cn/wp-content/uploads/2018/02/XXXXX.jpg
    如何写这个规则。。
    新手入门,不太懂,望大神指导。
    9 条回复    2018-03-07 21:07:38 +08:00
    huihuimoe
        1
    huihuimoe  
       2018-02-28 01:30:51 +08:00 via Android
    xiaopc
        2
    xiaopc  
       2018-02-28 06:41:53 +08:00 via Android
    有个非官方的七牛 WP 插件
    https://wordpress.org/plugins/wpjam-qiniu/
    301 过去不太好 /t/362493
    galvinwang007
        3
    galvinwang007  
       2018-02-28 11:11:53 +08:00
    可以参考这个插件的实现
    https://wordpress.org/plugins/wpjam-qiniu/
    happylty
        4
    happylty  
    OP
       2018-02-28 12:54:28 +08:00
    @huihuimoe
    @galvinwang007 我设置的是纯静态,这俩不管用了。。。
    @xiaopc 那个帖子也没解决啊
    xiaopc
        5
    xiaopc  
       2018-02-28 15:20:16 +08:00 via Android
    @happylty 他那个 conf 是能 301 跳转的,他说没解决是 HTML 里的图片地址直接换成 CDN 的地址,那个要用 sub_filter
    话说 WP 纯静态干嘛,不是生成 cache 就行了吗
    happylty
        6
    happylty  
    OP
       2018-02-28 16:58:48 +08:00
    @xiaopc 我试了试好像没用。。。
    纯静态比非纯静态快了 1 秒呢
    xiaopc
        7
    xiaopc  
       2018-02-28 19:00:34 +08:00 via Android
    @happylty 贴一下 conf 全部内容呢
    happylty
        8
    happylty  
    OP
       2018-03-07 21:06:46 +08:00
    @xiaopc #真静态 BEGIN Super Static Cache
    location / {
    #ngx_http_gzip_static_module and ngx_http_gunzip_module Must Be Added To Nginx
    gzip_static always;
    gunzip on;

    if (-f $request_filename) {
    break;
    }
    if ($uri ~ /(.*)$){
    set $wpuri $1;
    set $sscfile $document_root/super-static-cache/$1;
    }
    set $ssc Y;
    if ($query_string !~ .*=.*){
    set $ssc "${ssc}Y";
    }
    if ($request_method != "POST"){
    set $ssc "${ssc}Y";
    }

    if (-f $sscfile.gz){
    set $ssc "${ssc}F";
    }
    if (-f $sscfile/index.html.gz){
    set $ssc "${ssc}I";
    }

    if ($ssc = YYYF){
    rewrite . /super-static-cache/$wpuri break;
    }
    if ($ssc = YYYI){
    rewrite . /super-static-cache/$wpuri/index.html break;
    }

    if (!-e $request_filename){
    rewrite . /index.php last;
    }
    }
    #End Super Static Cache
    happylty
        9
    happylty  
    OP
       2018-03-07 21:07:38 +08:00
    @xiaopc 那个没用所以就删了,这个是 Super Static Cache 插件要求的。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2926 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 11:12 · PVG 19:12 · LAX 04:12 · JFK 07:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.