Jump to content

Recommended Posts

Hello folks,

 

Say I advertise my website as http://example.com/ which then redirects to http://example.com/index.php

My problem is that when a user who came from http://example.com/ is redirected http://example.com/index.php the HTTP_REFERER is gone. Essentially, I have no clue where my traffic comes from if they go to http://example.com/ and not a specific page. Do you know of any workaround for this problem?

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/
Share on other sites

 

My problem is that when a user who came from http://example.com/ is redirected http://example.com/index.php the HTTP_REFERER is gone

 

Erm.. if they goto http://example.com/ it will load http://example.com/index.php, if your not getting the 'HTTP_REFERER' its highly likely the browser isn't sending it..

 

if you mean you have a page that redirects to another you could do this:~

<?php
$Ref = $_SERVER['HTTP_REFERER'];
$URL = "http://mysite.com";
header("Referer: $Ref");
header("Location: $URL");
?>

 

 

'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.

 

if you mean you have a page that redirects to another you could do this:~

<?php
$Ref = $_SERVER['HTTP_REFERER'];
$URL = "http://mysite.com";
header("Referer: $Ref");
header("Location: $URL");
?>

No, I'm not using any php to redirect visitors. It happens because of some magic on the server. You type in http://example.com and it sends you automatically to http://example.com/index.html or index.asp or index.php etc.

 

I suppose if I wanted to word my question differently, it would be: How do I figure out what the value of $_SERVER['HTTP_REFERER'] was when my user got to http://example.com but before the server sent him/her http://example.com/index.php

It happens because of some magic on the server. You type in http://example.com and it sends you automatically to http://example.com/index.html or index.asp or index.php etc.

 

No it LOADS that page.. when you goto a folder on the server.. the server checks for pages

ie

index.htm

index.html

index.php

default.php

etc etc

 

its NOT redirecting you..

try it

if the HTTP_REFERER isn't passed when you goto http://example.com it will not be passed even if you goto http://example.com/index.php

 

if the page you load is not been passed the HTTP_REFERER then the clients browser isn't sending one..

in other words its out of your control..

 

 

When I was already thinking that I was going insane I figured out what I was doing wrong and I'm so ashamed that I won't even tell you what it was  :-[

 

Anyway, thanks for your help MadTechie and I apologize for wasting your time as the problem really lay elsewhere (in my flawed logic).

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.