Jump to content

HTTP_REFERER is null


gobob

Recommended Posts

I have a normal HTML link on an html page on one site pointing to a test.php file on another site.

 

I want to get the URL of the refering page using PHP, but have so far been unsuccessful.

 

Both $_SERVER['HTTP_REFERER'] and getenv('HTTP_REFERER') provide null results.

 

Also, phpinfo() does not display the HTTP_REFERER.

 

I can successfully get the remote IP addresses with $_SERVER['REMOTE_ADDR'].

 

JavaScript successfully displays the correct refering URL with:

 

<script language=javascript>document.write(referer);</script>

 

so, apparently, the header information is available.

 

I have tried this with MSIE and Firefox browsers.

 

I have also placed the test.php file on two different servers, but in each case PHP failed to find the refering URL.

 

Any suggestions would be helpful.

Link to comment
Share on other sites

I have tried that.

 

I believe the key is that phpinfo() displays nothing for HTTP_REFERER.

 

In that case I would not expect and PHP variable or function to provide the referer URL.

 

Since I am new at PHP, I have to ask, should PHP display a value for HTTP_REFERER when a .php file is requested by a normal HTML link?  Or am I striving in vain for something that normally does not work?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.