I want to get the current domain so if the page is http://www.domain.com/page.asp I need www.domain.com
Asked
Active
Viewed 1.9k times
15

Andrew G. Johnson
- 26,603
- 30
- 91
- 135
4 Answers
29
Request.ServerVariables("SERVER_NAME")'
To be complete, one of my functions:
function PageUrl
dim sPort
sPort = Request.ServerVariables("SERVER_PORT")
if sPort = "80" then
sPort = ""
else
sPort = ":" & sPort
end if
PageUrl = "http://" & Request.ServerVariables("SERVER_NAME") & sPort & _
Request.ServerVariables("URL") & "?" & _
Request.ServerVariables("QUERY_STRING")
end function

Edelcom
- 5,038
- 8
- 44
- 61
1
One of the Request Servervariables (server_name?)

bryanjonker
- 3,386
- 3
- 24
- 37
-
<%= Request.ServerVariables("SERVER_NAME") %> – jessegavin Jan 27 '10 at 17:31
0
<%
for each x in Request.ServerVariables
response.write(x&"="&Request.ServerVariables(x)&"<br>")
next
%>
This will gives you results like this with all Request.ServerVariables
REMOTE_ADDR = 40.20.170.160
REMOTE_HOST = 40.20.170.160
REMOTE_USER =
REQUEST_METHOD = GET
SCRIPT_NAME = /xyz/get.asp
SERVER_NAME = www.xyz.com
SERVER_PORT = 80

MRRaja
- 1,073
- 12
- 25
0
Put this before the end of your function to remove the ?
when there is no querystring element, as a random ?
at the end may not be what you want:
If right(PageUrl,1)="?" then PageUrl = left(PageUrl,len(PageUrl)-1)

Lee
- 1