1

我想创建一个从两个不同的 url 重定向到一个 URL 的重定向。我希望这个问题有一个简单的答案,我实际上已经提供了我在下面使用的示例代码,只是想知道我是否可以在下面的代码中添加另一个 URL,也许可以使用“else if”语句......谢谢您的帮助

<%@ Language=VBScript %>
<%
servername = Request.ServerVariables("HTTP_HOST")
if trim(Request.ServerVariables("HTTP_HOST")) = "levi.com" or 
trim(Request.ServerVariables("HTTP_HOST")) = "levis.com" then

url = "http://www.timoloud.com/"
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", url
Response.End
end if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="Javascript">
function redirect() {
    window.location.href = 'http://www.levi.com/timoloud.com';
}
</script>
</head>
<body onload="redirect();">
</body>
</html>
4

2 回答 2

2

使用Select Case语句可能更容易做到这一点。

Select Case Request.ServerVariables("HTTP_HOST")
    Case "levi.com", "levis.com", "other.com", "another.com"
        url = "http://www.timoloud.com/"
        Response.Status = "301 Moved Permanently"
        Response.AddHeader "Location", url
End Select
于 2012-05-07T04:41:48.650 回答
0

我不太清楚,但我想你想要这样的东西

<%@ Language=VBScript %> 
<% 
servername = Request.ServerVariables("HTTP_HOST")
redirectedUrls = "/levi.com/levis.com/"
if instr(redirectedUrls,"/" & servername & "/") then
  url = "http://www.timoloud.com/" 
  Response.Status = "301 Moved Permanently" 
  Response.AddHeader "Location", url 
  Response.End 
end if 
%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<script language="Javascript"> 
  function redirect() { 
    window.location.href = 'http://www.<%=servername%>/timoloud.com'; 
  } 
</script> 
</head> 
<body onload="redirect();"> 
</body> 
</html> 
于 2012-05-07T07:34:47.727 回答