网站域名限制和对非允许的域名进行强制301跳转
只要在网站的filter里面添加如下内容即可。判断访问域名,如果不是允许的,就写脚本强制跳转到指定域名。
?
?boolean allowFlag = false;
????? for(int i=0; i<serverNameList.length;i++){
????? ?if(serverNameFrom.indexOf(serverNameList[i])>-1){
????? ??allowFlag=true;
????? ??break;
????? ?}
????? }
????? if(!allowFlag){
????? ?response.getWriter().write("<html><head><title>www.hopechart.com</title><meta http-equiv="content-type" content="text/html; charset=gbk" /><meta http-equiv="refresh" content="0; url=http://www.hopechart.com/" /></head><body>click here :<a href='http://www.hopechart.com'>www.hopechart.com</a></body></html>");
????? ?System.out.println(serverNameFrom+" is not allowed!");
//????? ?System.exit(0);
????? ?return ;
????? }