将停放的域页重定向到新域中的所有共存页面

时间:2018-06-04 06:10:36

标签: javascript html .htaccess google-analytics

我有两个域运行所有相同的页面,其中一个停放,但两个域上的所有页面完全相同。

我需要解决的问题是,谷歌索引的所有网页都来自停放的域名,需要重定向到新的域名页面

例如www.parked.com/notparked.html到www.live.com/notparked.html

有关如何做到这一点的任何帮助?它甚至可能吗?

1 个答案:

答案 0 :(得分:0)

你的意思是同一条道路吗?

两者在JavaScript中具有相同的location.pathname,

因此您可以轻松使用http://your.new.host concat window.location.pathname获取新网址。

例如:

$('a').click(function(event){
   event.preventDefault();
   window.location.href = "http://your.new.host" + window.location.pathname;
})