温馨提示×

如何通过js代码实现301跳转

小新
1569
2020-12-31 16:01:36
栏目: 编程语言

如何通过js代码实现301跳转

通过js代码实现301跳转的方法:

 在对应的网页文件中使用此JS代码可实现301跳转,比如将不带www的域名跳转到带www的域名,代码如下:

<script language=javascript> 

if (document.domain ==""yisu.com"") 

this.location = ""http://www.yisu.com"" + this.location.pathname + this.location.search; 

</script>

0