JS code for Domain name conversion

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

When your site is bound to a number of domain names, want to let other domain name jump to a domain name, but also want the domain name after the URI address unchanged. That is to
http://www.xxxxxx.com/aa/aa.php?abc=123#456
http://www.yyyyyy.net/aa/aa.php?abc=123#456
http://www.zzzzzz.net/aa/aa.php?abc=123#456 When multiple domain names are automatically converted to
http://www.4181.cn/aa/aa.php?abc=123#456

I have not found the relevant methods on the Internet, and then self-study PHP, access to JavaScript, just know to achieve this function is very simple, PHP write this function can only be used for PHP programs, so I provide JavaScript code to achieve this function, Hope to give a little help to the novice friend who needs this code. In fact, this code is also very simple, using only JavaScript Location objects and if statements.

<script language= "javascript" type= "Text/javascript" >
<!--
var abc = "www.4181.cn";
var qwe = Window.location.host;
if (qwe!= ABC) {
window.location = "http://" + ABC + window.location.pathname + window.location.search + window.location.hash;
}
-->
</script>

Place the above code between <head></head> (note: replace my domain name with your own domain name).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.