Method of 301 permanent redirection in ASP and IIS

Source: Internet
Author: User

Website Domain name: www.***.com

Achieve the goal: input www.***.com or ***.com are able to enter the primary domain name www.***.com

System Category: ASP Class website

Prerequisites: The Site Administration panel can set the default home page

ASP Implementation Program

Example 1

The code is as follows Copy Code

<%
Website=request. ServerVariables ("SERVER_NAME")
' Get the domain name of the current access
If website= "icoa.cn" Then
' Judge if your domain name is icoa.cn
Response.status= "Moved Permanently"
Response.AddHeader "Location", "http://www.icoa.cn/"
' Do 301 Redirect to www.icoa.cn
End If
%>

Example 2

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>

The code is as follows Copy Code

<%

Response.status= "Moved Permanently"

Response.AddHeader "Location", "http://www.aaa.com/index.html"

Response.End

%>

If you have your own server, we can use IIS to achieve 301 redirect, first of all, a new site under IIS, Old Bar binding (http://lao8.org)

, specify the directory where the Web site is located, and then check "redirect to URL" in the home directory to fill in the URL that you want to jump, and check "permanent Redirection of resources"

1, in your IIS home directory-> redirect url-> Enter the URL to be directed to (such as: http://www.111cn.net/)
2, then the following permanent orientation of resources to select, as shown in the following figure.

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.