首页 > 解决方案 > 将某些内容从子域重定向到不同的域

问题描述

尽管这是与 Wordpress 相关的,但这个概念离这里讨论的距离还很远。

我有一个子域:blog.bla.com 我在这个子域上有数百篇文章,需要将其中一些重写到一个新域:bla.com/newPosts

使用 .htaccess 301 重定向我对该主题的研究表明我应该能够简单地说:

Rewrite 301 "blog.bla.com/test/article" "bla.com/test/article

但这不起作用。Wordpress 的可用 (php) 插件也无法在子/域之间传输。

任何帮助表示赞赏。

标签: phpwordpress.htaccess

解决方案


将此规则添加到 blog.bla.com .htaccess 文件的顶部

RewriteEngine On
RewriteRule ^test/article$  http://bla.com/test/article  [R=301,L]
RewriteRule ^test/article2$ http://bla.com/test/article2 [R=301,L]
RewriteRule ^test/article3$ http://bla.com/test/article3 [R=301,L]

推荐阅读