Get referer

On site www.domain1.com i have:

<img src="http://www.domain2.com/123/banner.gif">

On www.domain2.com i have a rewriterule
RewriteRule ^([^*]+)/banner.gif img.php

So that will pot to a img.php ...

How do i get the referer of domain1.com ?

I have this $_SERVER var when i access it

REDIRECT_UNIQUE_ID => 4uXUKsCoABEAAPKmUjEAAAH6
REDIRECT_STATUS => 200
UNIQUE_ID => 4uXUKsCoABEAAPKmUjEAAAH6
HTTP_ACCEPT => */*
HTTP_REFERER => http://www.domain1.com
HTTP_ACCEPT_LANGUAGE => ro
HTTP_UA_CPU => x86
HTTP_ACCEPT_ENCODING => gzip, deflate
HTTP_USER_AGENT => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2)
HTTP_HOST => www.domain2.com
HTTP_CONNECTION => Keep-Alive
HTTP_COOKIE => cc=RO; _sort=site_unique; phpbb2mysql_sid=63b380490674ebc34b4a2e5bd9c76f60; PHPSESSID=q1c808bnq11ekclbpj1eg17nc4
PATH => /usr/bin:/bin
SERVER_SIGNATURE =>
SERVER_SOFTWARE => Apache/2.2.8 (FreeBSD) mod_ssl/2.2.8 OpenSSL/0.9.7e-p1 DAV/2 PHP/5.2.5 with Suhosin-Patch
SERVER_NAME => www.domain2.com
SERVER_ADDR => 1.2.3.4
SERVER_PORT => 80
REMOTE_ADDR => 10.0.0.1
DOCUMENT_ROOT => /usr/home/user/public_html
SERVER_ADMIN => admin@admin.com
SCRIPT_FILENAME => /usr/home/user/public_html/img.php
REMOTE_PORT => 64463
REDIRECT_URL => /123/banner.gif
GATEWAY_INTERFACE => CGI/1.1
SERVER_PROTOCOL => HTTP/1.1
REQUEST_METHOD => GET
QUERY_STRING =>
REQUEST_URI => /123/banner.gif
SCRIPT_NAME => /img.php
PHP_SELF => /img.php
REQUEST_TIME => 1202641894


In this case my HTTP_REFERER is actualy the page from witch <img src="http://www.domain2.com/123/banner.gif"> is located.
rares_dumitrescuAsked:
Who is Participating?
 
ravenplConnect With a Mentor Commented:
Unless www.anotherdomain.com refers Your image - no.
0
 
ravenplCommented:
> How do i get the referer of domain1.com ?
Well, the $_SERVER['HTTP_REFERER'] have the value.
What else You asking for?
0
 
rares_dumitrescuAuthor Commented:
No, the $_SERVER['HTTP_REFERER']  is actually the url of the domain from where http://www.domain2.com/123/banner.gif has been accesed

If i access www.domain1.com (where http://www.domain2.com/123/banner.gif exists) from www.anotherdomain.com on img.php the $_SERVER['HTTP_REFERER'] will be www.domain1.com not www.anotherdomain.com
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ravenplCommented:
That's correct.
First You on www.anotherdomain.com. Fome that page clicks www.domain1.com link. The main script (index.php, index.html etc) should have referrer set to to www.anotherdomain.com, but images loaded should already have www.domain1.com as referrer.
Why would You expect something else? The link to banner.gif exists on www.domain1.com, not on www.anotherdomain.com.
0
 
rares_dumitrescuAuthor Commented:
Hmmm ....
This is the system

On www.domain1.com i have (<img src="http://www.domain2.com/123/banner.gif">)

From www.anotherdomain.com i go to www.domain1.com.

The php script from domain2.com will se Referer as www.domain1.com, not www.anotherdomain.com
0
 
ravenplCommented:
> On www.domain1.com i have (<img src="http://www.domain2.com/123/banner.gif">)
That why You getting www.domain1.com as referer

If the <img src="http://www.domain2.com/123/banner.gif"> had been on www.anotherdomain.com, You would see www.anotherdomain.com in referer.

So basically, what is happening
You (browser) are on www.anotherdomain.com, then You clicking on www.domain1.com link. This will fetch
www.domain1.com/index.php (or index.html or whatever index is pointing to). The index.php will have referer set to www.anotherdomain.com. The index.php have the image link <img src="http://www.domain2.com/123/banner.gif">. The browser will fetch it automatically giving index.php (www.domain1.com/index.php) as referer. It's the www.domain1.com who refers http://www.domain2.com/123/banner.gif - isn't it?
0
 
rares_dumitrescuAuthor Commented:
So is not possible to get www.anotherdomain.com as referer no ? ...
0
All Courses

From novice to tech pro — start learning today.