[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9815
  • Last Modified:

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
0
Tony-laptops
Asked:
Tony-laptops
  • 3
1 Solution
 
hongjunCommented:
You can use these 3 combinations

Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") & Request.ServerVariables("QUERY_STRING")
0
 
hongjunCommented:
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
0
 
hongjunCommented:
If in JavaScript,

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


hongjun
0
 
WilliamStamCommented:
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

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now