Use the. htaccess file for 301 redirection. Please refer to my other article. Article 301 redirection, jump to new domain name after domain name change
.
If the space does not support. htaccess files, we can also use PHP/asp Code To perform 301 redirection.
In order to update the record of the search engine to the current domain name, we have made several 301 redirection tasks to share with you.
ASP 301 redirection code
Add the following lines to the top of index. asp or default. asp:
Copy code The Code is as follows: <%
Response. Status = "301 moved permanently"
Response. addheader "location", "http://www.jb51.net /"
Response. End
%>
PHP 301 redirection code
Add the following lines to the top of index. php:Copy codeThe Code is as follows: <? PHP
Header ("HTTP/1.1 301 moved permanently ");
Header ("Location: http://www.jb51.net /");
Exit ();
?>
Asp.net 301 redirection codeCopy codeThe Code is as follows: <% @ page Language = "C #" %>
<SCRIPT runat = "server">
Protected void page_load (Object sender, eventargs E)
{
HTTP context. Current. response. statuscode = 301;
Httpcontext. Current. response. Status = "301 moved permanently ";
Httpcontext. Current. response. addheader ("location", "http://www.jb51.net ");
}
</SCRIPT>
301 stands for permanent transfer (permanently moved). 301 redirection is the best method for search engine friendliness after a webpage address is changed. Only
If it is not for temporary migration, we recommend that you use 301 for address conversion.
301 redirection under JSPCopy codeThe Code is as follows: <% @ page Language = "Java" pageencoding = "GBK" %>
<%
Response. setstatus (response. SC _moved_permanently );
Response. addheader ("location", "http://www.7hinet.com ");
%>
You can use filter to control the path or page to be redirected.