2013年10月11日星期五

Jiji Ji . . java linux tomcat 301 redirect

web development , the server is tomcat, the system is linux. This domain name without the www want to turn to the band www domain name. Site search out a generation of code, but I do not know how to do .
------ Solution ---------------------------------------- ----
made ​​three posts a no knot
------ For reference only ---------------------- -----------------
  This reply was moderator deleted at 2012-01-06 17:21:34

------ For reference only ---------------------------------- -----
made ​​three posts but could not find an answer .
------ For reference only -------------------------------------- -
this is not simple . tomcat want to bind multiple host names , you can use Alias.
example:
appBase = "webapps"
name = "baidu.com">
www.baodi.com
hi.baidu.com
www.google.com
....



------ For reference only ---------------------------------- -----
amount and the minute ?
------ For reference only -------------------------------------- -
301 redirect
301 redirect to achieve the effect : the search engine to index only the new URL , while under the old address will External links shown with the original move to new addresses , so as not to make your site rank as URL changes in affected in the slightest . Similarly, using a 301 permanent redirect command allows multiple domain names point to the main domain site , nor will your site's ranking any negative impact . Therefore, a 301 redirect is the most effective URLs that redirect a way .

String requestPage = request.getRequestURI();   
String queryString = (request.getQueryString() == null ? "" : "?"+request.getQueryString()); 
if(request.getRequestURL().indexOf("http://51chaozhi.com") >=0) {

response.setStatus(301);   
response.setHeader( "Location", "http://www.51chaozhi.com"+requestPage+queryString);
response.setHeader( "Connection", "close" );
}

------ For reference only ----------------------------------- ----
http://www.dreamxyt.net/487.html

没有评论:

发表评论