提问人:Khan 提问时间:9/23/2023 最后编辑:Khan 更新时间:9/28/2023 访问量:27
如何使用htaccess将博客重定向到另一个网址
How to redirect blog to another url using htaccess
问:
我最近将我的博客移到了谷歌正在寻找不存在的沼泽页面的问题上,我想使用 htaccess 重定向各个博客,如下所示:https://mobileframers.com/blog
https://blog.domain.com
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
答:
0赞
volkerschulz
9/28/2023
#1
要将所有请求从具有子目录的旧域重定向到没有子目录的新域,同时保留路径的其余部分和完整的查询字符串,请在 .htaccess 中使用mod_rewrite:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/blog/(.*)$
RewriteRule ^(.*) https://blog.mobileframers.com/%1 [R=301,NC]
评论
Redirect