该系统找不到指定的路径

时间:2011-05-20 20:20:54

标签: asp-classic iis-6

这是设置......

我正在尝试将websiteA.com重定向到websiteB.com

我的计划是使用websiteA.com上的自定义404.asp页面301重定向到websiteB.com

以下是我的404页面的摘录:

Response.Status="301 Moved Permanently"
select case lcase(request.servervariables("QUERY_STRING"))
     case "http://redirect.websiteA.com/1234.asp"
          Response.AddHeader "Location","http://www.websiteB.com/1234.aspx"
     case else
          Response.AddHeader "Location","http://www.websiteB.com/"
end select

为了测试我的404页面,我在websiteA.com上设置了一个子域名,我们称之为redirect.websiteA.com

我在redirect.websiteA.com上设置了default.asp,浏览器正确解析了http://redirect.websiteA.com。但是,当浏览器尝试解析http://redirect.websiteA.com/folderThatDoesntExist/时,我收到错误“系统无法找到指定的路径”

我在IIS的自定义错误部分为redirect.websiteA.com设置了404.asp

我做错了什么?

2 个答案:

答案 0 :(得分:1)

试着看看你从lcase(request.servervariables("QUERY_STRING"))得到什么,我打赌你会得到像404这样的东西;在网址之前。

在我的一个项目中,我使用这个丑陋的代码来清理字符串:

  temppath=replace(replace(replace(replace(Request.ServerVariables("QUERY_STRING"),"404;",""),":80",""),":443",""),"//","/")

  strFileName     = mid(temppath,instrrev(temppath,"/")+1,len(temppath))
  temppath= mid(temppath,instrrev(temppath, Request.ServerVariables("SERVER_NAME"))+len(Request.ServerVariables("SERVER_NAME")),len(temppath))

答案 1 :(得分:0)

在IIS中,您可以将sites目录更改为重定向到URL 输入URL并指定其他选项,例如
 1.上面输入的确切URl  2.输入的URL下面的目录
 3.此资源的永久重定向