Most people use virtual space. This article explains how to use a virtual space that supports ASP to set up 301 redirection. However, your program must be a full-site ASP. If you generate a static program, it will not work. Not much to say. Say, let’s continue: For example, your current domain name: www.a.com For some reason, you want to change the domain name to www.b.com, but you are afraid of losing traffic. What should you do? Don’t be afraid. You can use 301 redirection. Put www.a.com Or www.a.com/* all will be directed to www.b.com or www.b.com/* domain name.
Use your virtual space to bind www.a.com and www.b.com at the same time. Find the conn.asp or head.asp files in your asp program, which are files that can be accessed by the entire site. They are at the top. Just add the following code.
In this way, your access to www.b.com is normal, but when accessing www.a.com, it will automatically jump to the domain name of www.b.com to access www.a.com/*. Access to the following web pages will also automatically jump to all www.b.com/* below.
<%
if request.ServerVariables(HTTP_HOST)<>www.b.com then
if Request.ServerVariables(SCRIPT_NAME)=/index.html then
Response.Status=301 Moved Permanently
Response.AddHeader Location,/index.html
else
if Request.ServerVariables(QUERY_STRING)<> then
p=?
else
p=
end if
Response.Status=301 Moved Permanently
Response.AddHeader Location,http://www.b.com&Request.ServerVariables(SCRIPT_NAME)&p&Request.ServerVariables(QUERY_STRING)
Response.End
end if
end if
%>
If you are not using a full-site dynamic program, but a static program, please use the following code to perform a 301 permanent redirection of the domain name, that is, the homepage.
301 redirection of ASP program
<%
Response.Status=301 Moved Permanently
Response.AddHeader Location,http://www.vevb.com
%>
301 redirect under PHP
301 redirect for PHP program
<?
Header(HTTP/1.1 301 Moved Permanently);
Header( Location: http://www.vevb.com );
?>
301 redirect for ASP.NET program
<script runat=server>
PRivate void Page_Load(object sender, System.EventArgs e)
{
Response.Status = 301 Moved Permanently;
Response.AddHeader (Location,http://www.vevb.com);
}
</script>