Previously maintained a site needs to change the domain name, so to do the domain name jump settings. Collected a bit of information found, this one thought "simple" a jump, or a little attention to the "learning".
The HTTP protocol is known to all, and the return header has a status field that is used to indicate some state of the returned information. For example, we are familiar with 200,404,500 and so on. One of the more common is the 302 redirect, the browser receives this return value, recognizes this 302 redirect State, will read the header information in the Location field contained in the redirect URL, and then access the new address.
It sounds like this 302 redirect and the domain we need to jump a bit, but here is a problem, our site is a certain weight and the like to mark the site's traffic, such as data, if we change the new domain name, this kind of information is lost, so if the simple use of 302 Redirect to achieve the jump, Then the weight of our website and so on have to re-come, this is obviously not cost-effective.
Therefore, there is a similar jump status in HTTP, 301 permanent jump, this means that the current page to a permanent jump to a new page, the weight of the original site, and so on, will directly inherit the new website up. This is the way we change the domain name, guide users to access the new domain name, maintain the weight of the site before the use of the Jump method.
Here is an example of a simple implementation in JSP 2:
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
<%response.setstatus (301), Response.setheader ("Location", "http://www.ahwebs.com/"); Response.setheader (" Connection "," close ");%>
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"%> <% Stringservername=Request.getservername (); StringServerpath=Request.getservletpath (); Stringaddres="http://www.baidu.com"; Response.setstatus (httpservletresponse.sc_moved_permanently); Response.setheader (" Location", addres); %>
301 Jumps to the website