Last updated: August 27, 2026.
Build a relative URL from IIS variables. For an absolute canonical URL, combine the path with a configured trusted origin rather than the incoming Host header.
<%
Function CurrentRelativeUrl()
Dim value, query
value = Request.ServerVariables("URL")
query = Request.ServerVariables("QUERY_STRING")
If Len(query) > 0 Then value = value & "?" & query
CurrentRelativeUrl = value
End Function
Response.Write Server.HTMLEncode(CurrentRelativeUrl())
%><%
Const CanonicalOrigin = "https://www.example.com"
Response.Write Server.HTMLEncode(CanonicalOrigin & CurrentRelativeUrl())
%>Validate allowed hosts when supporting several domains. Encode a URL for its output context.