2015-10-17 62 views
-1

比方说,有人来到我的网站与这个网址:获取子链接将其加载到一个新的URL

mywebsite.com/somethingsomething123

我想创建一个新的URL和转它转换成:

anotherwebsite.com/somethingsomething123

我怎么能做到这一点?
任何帮助,将不胜感激。

+0

尝试使用'location.pathname';例如'var path = location.pathname; var newurl =“anotherwebsite.com”+ path;' – guest271314

回答

0

因此,使用JavaScript你这样的:

var path_Name; // it will be like somethingsomething123 
 
redirect_Url="www.example.com"; // anotherdomain.com 
 
function test(){ 
 
path_Name = window.location.pathname; 
 
window.location.href='http://'+redirect_Url+path_Name 
 
};
<button onClick="test()" >Click Here </button> 
 
<h3>I have used test() function on click event you can use it on window.onLoad or any other javascript event </h3>

注意:如果你想要做的使用URL重写则指定 它的Windows或Linux是否托管

+0

老实说,我的网址看起来像 mywebsite.com/qwerty=ok&hello=somethingsomething123所以其他网站 –

+0

也没有找到一个redirrect –

相关问题