p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Two URL's - One Site


Message #1 by "Jon Shoreman" <jon.shoreman@b...> on Sun, 7 Apr 2002 22:51:03
I have two URL's pointing to the same site / IP.

Using PHP is it possible to find out which URL the visitor is using?
Message #2 by "John Arbon" <subscriptions@c...> on Tue, 9 Apr 2002 06:04:00
I'm guessing that you are forwarding the client to the final site.  If so, 
I believe you can use the HTTP_REFERER variable to get the referring site 
address.

$referrer = $HTTP_REFERER;

John

Nik,

Did I get that right?  *)

> I have two URL's pointing to the same site / IP.

> Using PHP is it possible to find out which URL the visitor is using?
Message #3 by "Nikolai Devereaux" <yomama@u...> on Mon, 8 Apr 2002 23:57:47 -0700

Heh, I have no idea.  I think it's possible because I've got several domain
names pointing to the same place.

Many people have whatever.com, .net, and .org all point to the same site, so
that might be what he's talking about.  Or maybe they have www.whatever.com,
mail.whatever.com, cvs.whatever.com, and whatever.whatever.com all point to
the same machine.

After re-reading the predefined variables page in the php manual, I don't
think that http_referrer will help much -- that tells you (MAYBE) what site
the user was on BEFORE accessing your site, not necessarily the link they
used to access your site.

I guess all you can do is try to ensure that all the links in your site are
relative.  Relative to the site root is fine, but don't ever create links
that have a server name in them if you're only linking between pages of the
same site.


Take care,

Nik

Message #4 by "Lawrence" <lkrubner@g...> on Tue, 9 Apr 2002 13:32:08 -0400
Javascript can solve this problem much more easily.


----- Original Message ----- 
From: "Nikolai Devereaux" <yomama@u...>
To: "beginning php" <beginning_php@p...>
Sent: Tuesday, April 09, 2002 2:57 AM
Subject: [beginning_php] Re: Two URL's - One Site


> 
> 
> Heh, I have no idea.  I think it's possible because I've got several domain
> names pointing to the same place.
> 
> Many people have whatever.com, .net, and .org all point to the same site, so
> that might be what he's talking about.  Or maybe they have www.whatever.com,
> mail.whatever.com, cvs.whatever.com, and whatever.whatever.com all point to
> the same machine.
> 
> After re-reading the predefined variables page in the php manual, I don't
> think that http_referrer will help much -- that tells you (MAYBE) what site
> the user was on BEFORE accessing your site, not necessarily the link they
> used to access your site.
> 
> I guess all you can do is try to ensure that all the links in your site are
> relative.  Relative to the site root is fine, but don't ever create links
> that have a server name in them if you're only linking between pages of the
> same site.
> 
> 
> Take care,
> 
> Nik
> 
> 

Message #5 by "Nikolai Devereaux" <yomama@u...> on Mon, 15 Apr 2002 12:23:41 -0700
> Javascript can solve this problem much more easily.

How so?

When I said this:

> > I guess all you can do is try to ensure that all the links in 
> > your site are relative.  Relative to the site root is fine,
> > but don't ever create links that have a server name in them if
> > you're only linking between pages of the same site.
Message #6 by "Nikolai Devereaux" <yomama@u...> on Mon, 15 Apr 2002 12:27:22 -0700
dammit, I did it again.  I sent the email before I was done.

Lemme finish now.

When I said this:

> > I guess all you can do is try to ensure that all the links in
> > your site are relative.  Relative to the site root is fine,
> > but don't ever create links that have a server name in them if
> > you're only linking between pages of the same site.

This should solve any problems of putting the domain anywhere and not having
to keep track of how a user gets there to ensure that they stay on the same
server.  It doesn't take that much of a time difference to write relative
vs. absolute links, if anything, it takes LESS time since there's less
typing involved!

A javascript solution forces the client to have a browser that can handle
javascript.  You're also creating a page that takes longer to download and
load (very slightly, yes, but still.)

I don't see any benefit to introducing a bunch of javascript into the mix
when an elegant approach to writing code can completely circumvent the need
for a bunch of "fancy" bug ugly hacks.


nik


  Return to Index