Forum Moderators: open

Message Too Old, No Replies

How to get the domain?

         

tesla

7:40 pm on Aug 4, 2002 (gmt 0)

10+ Year Member



What is the method that will return the URL or domain of a page.

Right Now I have the URL hard coded in a few locations where relative paths don't work. THe problem is that as I move between the real site and the test site, the domain changes and I have to manually change the code.

There must be an object that returns the domain or the URL....I Hope.

TESLA

aspdaddy

12:47 pm on Aug 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In asp...
ServerVariables("URL")
ServerVariables("SCRIPT_NAME")

tesla

1:50 am on Aug 10, 2002 (gmt 0)

10+ Year Member




That does not seem to work. It just returns the path off the domain, without the domain itself.

For example
the page is domain.com/pages/page1
the function returns /pages/page1

This is the exact code I used.
<% response.write request.ServerVariables("URL") %>

AND

<% response.write request.ServerVariables("script_name")
returns the same thing.

<% response.write request.ServerVariables("server_name") %>

This seems to work.

[edited by: tesla at 2:03 am (utc) on Aug. 10, 2002]

korkus2000

2:00 am on Aug 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried
<%= "http://" & request.ServerVariables("HTTP_HOST") & request.ServerVariables("URL")%>

I don't know what your configuration is. If HTTP_HOST doesn't work try concatinating SERVER_NAME with URL. You may want to use the server variable code to check them all out.

<%
response.write "<table border=2>"
For Each Item in Request.ServerVariables
response.write "<tr><td>" & Item & "</td><td>" & Request.ServerVariables(Item) & "</td></tr>"
Next
response.write "</table>"
%>

tesla

2:07 am on Aug 10, 2002 (gmt 0)

10+ Year Member



Korkus,

That seems to work as well.

Thanks