1

2 つの異なる URL から 1 つの URL へのリダイレクトを作成したいと考えています。この質問に簡単な答えがあることを願っています。実際に以下で使用しているサンプルコードを提供しました。「else if」ステートメントを使用して、以下のコードに別の URL を追加できるかどうかを知りたかっただけです....ありがとうあなたの助けに

<%@ 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 に答える