301 redirection code under ASP, Asp.net, PHP, and JSP

Source: Internet
Author: User

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.

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.