How do i find out what URL a user entered to find my site.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

Will i find an aswer to my question

Yes
0
No votes
No
2
100%
 
Total votes: 2

phillcahill
Forum Newbie
Posts: 1
Joined: Mon Nov 07, 2005 3:41 pm
Location: uk

How do i find out what URL a user entered to find my site.

Post by phillcahill »

sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
Last edited by phillcahill on Sun Jul 17, 2011 4:25 pm, edited 1 time in total.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

You can try getenv('HTTP_REFERER'). I'm not sure if this can be accomplished using mod rewrite, but it would certainly be interesting.
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

heres a snippet i wrote to get referer info

Code: Select all

$_SERVER['HHTP_REFERER'];//get referring URL
$referring_url = $_SERVER['HTTP_REFERER']; //assign referring URL


//i believe if you change 'host' to 'path' you get the whole string
 
$parsed = (parse_url($referring_url)); //breaking this bad boy down
$uri = $parsed['host']; // calling the host from the referer URL
// echo "<BR>uri: " . $uri . ""; // testing purposes
good luck
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

reserved.variables wrote:'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it all depends on how these domains "point" to your actual domain. If they redirect to the main domain, asside from using a URL parameter to tell your main server where they are coming from, referrer is the only way to really know... If you remain on the other domain, but are accessing the main domain (rewriting/virtual host) then you can access what the server is through $_SERVER['HTTP_HOST']
Post Reply