ASP: 1.使用CASE语句,缺点:同一域名即@和www需要两次循环,代码显重复 <% host=lcase(request.servervariables("HTTP_HOST")) select CASE host CASE "www.abc.com" response.redirect "index.htm" CASE "abc.com" response.redirect "index.htm"
CASE ELSE response.redirect "other.htm" END select %> -------------------------- <%if instr(Request.ServerVariables ("SERVER_NAME"),"kekexi.com")>0 then response.redirect "index.asp" else if instr(Request.ServerVariables ("SERVER_NAME"),"4668.com")>0 then response.redirect "x/index.asp" else if instr(Request.ServerVariables ("SERVER_NAME"),"web315.com")>0 thenr esponse.redirect "index3.asp" end if end if
----------------------- <%if Request.ServerVariables("SERVER_NAME")="www.yyjs.com" then response.redirect "zkj" else response.redirect "i.htm" end if%>
---------------------------- <%if Request.ServerVariables("SERVER_NAME")="www.yyjs.com" then response.redirect "index1.asp" else if Request.ServerVariables("SERVER_NAME")="www.ce.org.cn" then response.redirect "index2.asp" else if Request.ServerVariables("SERVER_NAME")="www.163.com" then response.redirect "index3.asp" end if end if end if%>
2.为解决上述问题,可以加条件判断加上www. 这样就可以自动识别www前缀:
<% dim domain domain=request.ServerVariables("Server_Name") if instr(domain,"www.") then domain=right(domain,len(domain)-4) if domain="abc.com" then response.redirect "1/" elseif domain="123.com" then response.redirect "2/" else response.redirect "3/" end if %>