将特定类别页面重定向到子域

时间:2017-04-23 10:35:46

标签: apache .htaccess redirect

我已经尝试了一段时间但尚未找到解决方案。

我转移到wordpress,我的旧网站是自定义CMS。旧网站现在转到archive.example.com,而所有新帖子都将在http://example.com

上创建

我为新网站创建了不同的类别,以便它不会与旧网站的类别冲突。

我希望对旧类别页面的所有请求都转到archive.exampmle.com

例如:

http://example.com/apple 

应该去

http://archive.example.com/apple

另外, apple类别下的所有URL都应转到存档子域。例如:

http://example.com/apple/1234 

现在应该转到

http://archive.example.com/apple/1234

我试过这个

RedirectMatch 301 /apple/ http://archive.example.com/apple/$1

但它没有用。

1 个答案:

答案 0 :(得分:1)

尝试使用以下规则,

RewriteEngine On
RewriteCond %{REQUEST_URI} ^apple
RewriteRule ^ http://archive.example.com%{REQUEST_URI} [R=301,L]
相关问题