我最近将我的博客从
https://mobileframers.com/blog
移动到https://blog.domain.com
,问题是谷歌正在寻找不存在的博客页面,我想使用htaccess重定向个人博客,如下所示:
Redirect https://mobileframers.com/blog https://blog.mobileframers.com
Redirect https://mobileframers.com/blog/test-1 https://blog.mobileframers.com/test-1
Redirect https://mobileframers.com/blog/test-2 https://blog.mobileframers.com/test-2
要将所有请求从旧域with子目录重定向到新域without子目录,同时维护路径和查询字符串,请在.htaccess中使用mod_rewrite:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/blog/(.*)$
RewriteRule ^(.*) https://blog.mobileframers.com/%1 [R=301,NC]