Practical 301 switch to the ASP code of the corresponding page of another domain name

Source: Internet
Author: User
Tags servervariables

A few days ago, in order to enhance the SEO of this site, I switched 301 of all pages under another domain name: www.kanshule.com to www.jb51.net.

Since this site currently only has one blog, you can start with it.

The idea is very simple. Get the Domain Name of the current browser page. If it is the domain name that needs to be switched, replace the domain name part and use it as the new address for 301 redirection.

Code As follows:
Copy code The Code is as follows: <%

Dim todomain, fromdomain, curdomain, Q, P, URL

Todomain = www.jb51.net

Fromdomain = "kanshule.com"

Curdomain = request. servervariables ("http_host ")

If instr (curdomain, fromdomain)> 0 then

Q = request. servervariables ("QUERY_STRING ")

P = request. servervariables ("url ")

Url = "http: //" & todomain & P &"? Furl = kanshule.com"

If q <> "" Then url = URL & "&" & Q

Response. Status = "301 moved permanently"

Response. addheader "location", URL

Response. End ()

End if

%>

A parameter is added to the URL to record how many accesses are accessed from this domain name.

Save the file as an ASP file, including any ASP page to jump.

In the blog, you can call the public database connection file conn. asp. I will include this file in conn. asp.

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.