【问题标题】:How to determine if a website is set up as a virtual directory or not?如何确定网站是否设置为虚拟目录?
【发布时间】:2014-04-25 03:09:50
【问题描述】:

我有这个经典的asp代码:

'code start
https = lcase(request.ServerVariables("HTTPS")) 
if https <> "off" then prot = "https" else prot ="http"

'use the following for website (non-virtual)
TheURL1 = prot&"://"&Request.ServerVariables("SERVER_NAME")&"/"

'use the following for virtual directory website
TheURL2 = prot&"://"&Request.ServerVariables("SERVER_NAME")&"/Tawanda/NewTawanda/"
'code end

我使用它来确定根 URL(例如http://myserver/),但我注意到当网站配置为虚拟目录时,如果它不是虚拟目录,我必须使用 TheURL2 和 TheURL1。

我的问题是如何确定(在经典 asp 中)网站是否配置为虚拟目录,以便我可以将此代码放在 if... then... 语句中?

【问题讨论】:

    标签: asp-classic


    【解决方案1】:

    您可以查询APPL_MD_PATH的ServerVariables值。

    当您不在虚拟目录(常规网站)下运行应用程序时,该值应以 ROOT 结尾,如果不是,则您位于虚拟目录中。

    试试这个:

    ' 检查 APPL_MD_PATH 的值 If Request.ServerVariables("APPL_MD_PATH").EndsWith("/ROOT") Then '将以下内容用于网站(非虚拟) TheURL1 = prot&"://"&Request.ServerVariables("SERVER_NAME")&"/" 别的 '将以下内容用于虚拟目录网站 TheURL2 = prot&"://"&Request.ServerVariables("SERVER_NAME")&"/Tawanda/NewTawanda/" 万一 '代码结束

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多