get a referring URL

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
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

get a referring URL

Post by paladaxar »

Is there any way that I can find out what site linked to my site? I want to get the URL and store it in a DB. But, I dont want anything past the .com. so if (for example) someone got to my site by clicking on an ad on eBay, and the referring URL was http://www.ebay.com/categories/books/calculus.php I would only want "http://www.ebay.com". Is this possible?

Thanx,
Josh
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

parse_url(). Be aware that looking for a referrer in a request is very unreliable as it's extremely easy to fake and there are routers that strip that information from a request..
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

... but if you reaaally want it, try: getenv( "HTTP_REFERER" );
Post Reply