Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking Web Traffic-Multiple domain names 2

Status
Not open for further replies.

TheLoneCoder

Programmer
Apr 20, 2004
7
US
OK, I know I can point multiple domain names to the same virtual folder in IIS. (or at least I think I can)

If I do that, is there any way of tracking which address the visitor is using?

My boss swears that "everyone" is doing this. I'm supposed to figure out how.

 
There are a couple of different ways to do this. If you are running ASP, then you can get it from the server variables:
Code:
request.ServerVariables("HTTP_HOST")

Or if you prefer client side javascript:

Code:
window.location.href;

Or perhaps PHP's Server Variables:

Code:
$_SERVER['HTTP_HOST'];

Hope that is useful.
 
So even though there's only one actual page, if I use an asp script to make a database entry using request.ServerVariables("HTTP_HOST") it'll store the address the visitor typed in?

That's very helpful and should be easy to implement.

Thanks!
 
Yeah, each of those will grab from the part. As I tested each of the examples that I posted above, I tried accessing my local server by localhost, internal IP, machine name, external IP, and finally, external web name. Each time the same script put whatever was in between the first set of slashes.

That will let you get whatever is in the user's browser (whichever of your names they chose) and do with it as you wish.

Glad to help.
 
Will it work if the user enters or if both are pointing to the same web application?

That's what I need to track.

I need to know that 60% of visitors are using the first URL and the rest are using the other one without having to maintain two copies of all my pages.
 
Yes. That's what I was talking about in my last post when I talked about how I tested it all of those different ways.

When I put in:

I got peterbilt
I got 192.168.0.1
I got localhost

All 3 are ways to get to the same page on the same machine, but I was able to ascertain whether my page was accessed my domain name or ip address and then, which one of either was used, exactly what you need.
 
Perfect!!! [flowerface]

That is exactly what I need.

Thank you so much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top