request.serverVariables() "URL" vs "Script_Name"

Jiaaro picture Jiaaro · Mar 27, 2009 · Viewed 19.7k times · Source

I am maintaining a classic asp application and while going over the code I came across two similar lines of code:

Request.ServerVariables("URL")
' Output: "/path/to/file.asp"

Request.ServerVariables("SCRIPT_NAME")
' Output: "/path/to/file.asp"

I don't get it... what is the difference? both of them ignore the URL rewriting that I have set up which puts the /path folder as the root document (the above URL is rewritten to "/to/file.asp")

More info: The site is deployed on IIS 7

Answer

Max Wikström picture Max Wikström · Sep 23, 2010

URL Gives the base portion of the URL, without any querystring or extra path information. For the raw URL, use HTTP_URL or UNENCODED_URL.

SCRIPT_NAME A virtual path to the script being executed. Can be used for self-referencing URLs.

See, http://www.requestservervariables.com/url and /script_name for the definitions.