如何判断网站是否设置为虚拟目录?
我有这个经典的 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...
语句中?
I have this classic asp code:
'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
I am using it to determine the root URL (e.g. http://myserver/
) but I notice that when the web site is configured as a virtual directory I have to use TheURL2 and TheURL1 if its not a virtual directory.
My question is how can I determine (in classic asp) whether the web site is configured as a virtual directory or not so that I can place this code in an if... then...
statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查询APPL_MD_PATH的ServerVariables值。
当您不在虚拟目录(常规网站)下运行应用程序时,该值应以 ROOT 结尾,如果不是,则说明您位于虚拟目录中。
试试这个:
You can query the ServerVariables value of APPL_MD_PATH.
When you run your application not under a virtual directory (a regular web site), then the value should end with ROOT, if it doesn't, then you're in a virtual directory.
Try this: