最近在迁移博客( wordpress→静态页面),迁移后页面链接会有所变化,所以打算做个 301 重定向。 下载了相关的插件,不过楼主小白不会用。。特来咨询以下的问题:
原链接 https://xxx.com/blog/%postname%.html 新链接 https://xxx.com/post/%postname%.html
如果把原链接通过 301 重定向为新的链接,postname 这个变量需要用正则写么?如果需要的话,请问该怎么写呢?
求答案,🙏
最近在迁移博客( wordpress→静态页面),迁移后页面链接会有所变化,所以打算做个 301 重定向。 下载了相关的插件,不过楼主小白不会用。。特来咨询以下的问题:
原链接 https://xxx.com/blog/%postname%.html 新链接 https://xxx.com/post/%postname%.html
如果把原链接通过 301 重定向为新的链接,postname 这个变量需要用正则写么?如果需要的话,请问该怎么写呢?
求答案,🙏
|
InDomJun 24, 2022
1
rewrite ^/blog/(.*)\.html$ /post/$1.html permanent;
也许,可以不需要插件。 |
|
2
@InDom #1 请问这个是要写在哪里呢
|
|
PEALJun 24, 2022
3
@Superoutman nginx
|
|
novoluntJun 24, 2022
4
页面上请求内容也需要替换
sub_filter '/blog/' '/post/'; sub_filter_once off; sub_filter_types application/javascript text/css text/javascript application/json text/plain; |
|
5
@PEAL #3 Wordpress 用的是 Apache ,我是应该写在 .htaccess 里吧?
|
|
6
@novolunt #4 好的,感谢。就是不知道把这些写在哪里,hhh
|
|
wdssmqJun 24, 2022
7
这个插件目测要专业版才能有匹配模式?
|
|
wdssmqJun 24, 2022
8
RewriteRule ^blog/(.*)\.html$ /post/$1.html [L,R=301]
|
|
9
|