Superoutman
0.51D
V2EX  ›  WordPress

有关 301 重定向页面的求助

  •  
  •   Superoutman ·
    PRO
    · Jun 24, 2022 · 2691 views
    This topic created in 1595 days ago, the information mentioned may be changed or developed.

    最近在迁移博客( wordpress→静态页面),迁移后页面链接会有所变化,所以打算做个 301 重定向。 下载了相关的插件,不过楼主小白不会用。。特来咨询以下的问题:

    原链接 https://xxx.com/blog/%postname%.html 新链接 https://xxx.com/post/%postname%.html

    如果把原链接通过 301 重定向为新的链接,postname 这个变量需要用正则写么?如果需要的话,请问该怎么写呢?

    求答案,🙏

    Supplement 1  ·  Jun 24, 2022

    我还是用插件吧,更直白一点,不然各位说的我不会应用。。 伸个手,以下两个地址,我应该如何填写? jPOGVS.png

    9 replies  •  2022-06-24 11:46:53 +08:00
    InDom
    InDom
    Jun 24, 2022
    1
    rewrite ^/blog/(.*)\.html$ /post/$1.html permanent;

    也许,可以不需要插件。
    Superoutman
    Superoutman
    OP
    PRO
    Jun 24, 2022
    2
    @InDom #1 请问这个是要写在哪里呢
    PEAL
    PEAL
    Jun 24, 2022
    3
    novolunt
    novolunt
    Jun 24, 2022
    4
    页面上请求内容也需要替换
    sub_filter '/blog/' '/post/';
    sub_filter_once off;
    sub_filter_types application/javascript text/css text/javascript application/json text/plain;
    Superoutman
    Superoutman
    OP
    PRO
    Jun 24, 2022
    5
    @PEAL #3 Wordpress 用的是 Apache ,我是应该写在 .htaccess 里吧?
    Superoutman
    Superoutman
    OP
    PRO
    Jun 24, 2022
    6
    @novolunt #4 好的,感谢。就是不知道把这些写在哪里,hhh
    wdssmq
    wdssmq
    Jun 24, 2022
    7
    这个插件目测要专业版才能有匹配模式?
    wdssmq
    wdssmq
    Jun 24, 2022
    8
    RewriteRule ^blog/(.*)\.html$ /post/$1.html [L,R=301]
    Superoutman
    Superoutman
    OP
    PRO
    Jun 24, 2022
    9
    @wdssmq #8 OKOK ,好像明白了,左边写 https://xxx.com/blog/(.*)\.html$,右边写 https://xxx.com/post/$1.html ,这样对吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1412 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 19:06 · PVG 03:06 · LAX 11:06 · JFK 14:06
    ♥ Do have faith in what you're doing.