使用htaccess重定向页面的最佳方法

时间:2014-07-24 00:49:43

标签: regex .htaccess redirect

我即将合并两个网站域名。为了论证,可以说boo.com正在迁移到foo.com。我知道将boo重定向到foo是必须的。但是boo.com有一些排名很高的页面,需要大量的流量和我希望将这些流量发送到foo.com主页以外的其他地方。我的问题是......是否可以为特定页面设置重定向&然后通过htaccess重定向delta新域名主页?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

是的!这是可能的。

您所要做的就是在全局重定向之前放置特殊重定向。例如:

RewriteEngine On

# Redirect special pages
RewriteRule ^my_special_page_1 http://foo.com/special_1.html [L,R=301]
RewriteRule ^my_special_page_2 http://bar.com/special_2.html [L,R=301]
RewriteRule ^my_special_page_3 http://baz.com/special_3.html [L,R=301]

# Catch all the others
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [NE,R=301,L]