We have users coming into our homepage from two different servers. I would like to differentiate what gets shown (text, links, and so forth) based on the server that the user is coming through. Is it possible to identify what server is being used when the data is being accessed, and can you then conditionally show or not show data based on that information?
If your servers use Active Server Pages (ASP) you can determine the name of the server from which the page comes with ServerVariables.Request.ServerVariables(“HTTP_HOST”) will return the name of the Web server. You can then use that return value in an “If” statement to determine which HTML to show. For example:
<%If UCASE(Request.ServerVariables("HTTP_HOST")) = "SERVER1" Then%>
Show plain HTML<%else%>
Show italicized HTML<%end if%>
Note that I have wrapped the call to the ServerVariables in a UCASE() method. This is to ensure that the comparison will work regardless of uppercase or lowercase letters in the server name. Using the name of the server and the “If” statement, you can control which section of HTML gets written to the page, and which doesn’t.
As a bonus, here is some code that you may find useful. This code will display all of the ServerVariables and their values in a nice table. This demonstrates the types of information that you can retrieve from ServerVariables.
|" & x & "||" & Request.ServerVariables(x) & "|