Link to home
Start Free TrialLog in
Avatar of Tony-laptops
Tony-laptops

asked on

Request.ServerVariables("HTTP_URL") How to get full URL string?

Hi All,

I am trying to get the full url of a page, not having any luck in finding the correct code.

I am aware of these 2, but I need to get the full string that’s in the address bar of a page.

Request.ServerVariables("HTTP_URL")
Request.ServerVariables("HTTP_HOST")

Is there any other code that could pull the whole string?

Thank you.

Tony
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Think this is better

<%
Response.Write "http://"
Response.Write Request.ServerVariables("HTTP_HOST")
Response.Write Request.ServerVariables("URL")
if Request.ServerVariables("QUERY_STRING") <> "" then
      Response.Write "?" & Request.ServerVariables("QUERY_STRING")
end if
%>


hongjun
If in JavaScript,

<script language="JavaScript">
      alert(location.href);
</script>


hongjun
found this
<% 
    prot = "http" 
    https = lcase(request.ServerVariables("HTTPS")) 
    if https <> "off" then prot = "https" 
    domainname = Request.ServerVariables("SERVER_NAME") 
    filename = Request.ServerVariables("SCRIPT_NAME") 
    querystring = Request.ServerVariables("QUERY_STRING") 
    response.write prot & "://" & domainname & filename & "?" & querystring 
%>

Open in new window