Redirect 如何创建从两个不同URL重定向到一个URL的重定向?(见下面的代码)
我想创建一个从两个不同URL重定向到一个URL的重定向。我希望这个问题有一个简单的答案,我实际上已经提供了下面使用的示例代码&我只是想知道我是否可以使用“else-if”语句在下面的代码中添加另一个URL……谢谢你的帮助Redirect 如何创建从两个不同URL重定向到一个URL的重定向?(见下面的代码),redirect,asp-classic,vbscript,Redirect,Asp Classic,Vbscript,我想创建一个从两个不同URL重定向到一个URL的重定向。我希望这个问题有一个简单的答案,我实际上已经提供了下面使用的示例代码&我只是想知道我是否可以使用“else-if”语句在下面的代码中添加另一个URL……谢谢你的帮助 <%@ Language=VBScript %> <% servername = Request.ServerVariables("HTTP_HOST") if trim(Request.ServerVariables("HTTP_HOST")) = "lev
<%@ 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>
函数重定向(){
window.location.href=http://www.levi.com/timoloud.com';
}
使用选择案例
语句可能更容易做到这一点。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
我不太清楚,但我想你想要这样的东西
<%@ 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>
函数重定向(){
window.location.href=http://www./timoloud.com';
}
从服务器端完成这项工作不是更有效(也更高效)吗?