Asp,asp.net,php,jsp 301 Turn Code _ website application

Source: Internet
Author: User
Tags httpcontext change domain name
For 301 redirects using the. htaccess file, see my other article, "301 redirect, change domain name to new domain name"

If the space does not support the. htaccess file, then we can also use the Php/asp code for 301 redirects.
In order to update the search engine records to the current domain name above, did a few 301 redirect Dongdong, for everyone to share.
ASP 301 Steering Code
Add the following lines to the top of the index.asp or default.asp:
Copy Code code as follows:

<%
Response.status= "Moved Permanently"
Response.AddHeader "Location", "http://www.jb51.net/"
Response.End
%>

PHP 301 Steering Code
Add the following lines to the top of the index.php:
Copy Code code as follows:

<?php
Header ("http/1.1 moved Permanently");
Header ("location:http://www.jb51.net/");
Exit ();
?>

asp.net 301 Steering Code
Copy Code code as follows:

<%@ Page language= "C #"%>
<script runat= "Server" >
protected void Page_Load (object sender, EventArgs e)
{
HttpContext.Current.Response.StatusCode = 301;
HttpContext.Current.Response.Status = "Moved Permanently";
HttpContext.Current.Response.AddHeader ("Location", "http://www.jb51.net");
}
</script>

301 represents a permanent transfer (permanently moved), 301 redirect is the best way to search engine friendliness after a Web page change, only
If it is not temporarily moved, it is recommended that the 301来 be used as a transfer site.

301 redirects under the JSP
Copy Code code as follows:

<%@ page language= "java" pageencoding= "GBK"%>
<%
Response.setstatus (response. sc_moved_permanently);
Response.AddHeader ("Location", "http://www.7hinet.com");
%>

You can control the path or page that needs to be redirected through the filter

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.