ServerVariable to detect the home page of a web site in Classic ASP


You may like to include some data only if your visitors are in your front or root page, or to exclude some data in the same condition. In this case you need to Request.ServerVariables, but it won’t help to use the URL variable, although it seems relevant. You cannot also use the SERVER_NAME variable, since this is not unique for the front page.

To detect the home page, use the SCRIPT_NAME variable, making sure you won’t ignore that your condition is case sensitive.

Most probably your default document is named just this, “default”, but you need to use a capital D in order for your condition to work, as in this example:

If Request.ServerVariables(“SCRIPT_NAME”) = “/Default.asp” Then etc.

Enjoy!