don117 Posted March 30, 2008 Share Posted March 30, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/ Share on other sites More sharing options...
MadTechie Posted March 30, 2008 Share Posted March 30, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/#findComment-504458 Share on other sites More sharing options...
don117 Posted March 30, 2008 Author Share Posted March 30, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/#findComment-504467 Share on other sites More sharing options...
MadTechie Posted March 30, 2008 Share Posted March 30, 2008 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.. Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/#findComment-504470 Share on other sites More sharing options...
don117 Posted March 30, 2008 Author Share Posted March 30, 2008 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). Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/#findComment-504481 Share on other sites More sharing options...
MadTechie Posted March 30, 2008 Share Posted March 30, 2008 lol, happens to all of us.. Quote Link to comment https://forums.phpfreaks.com/topic/98559-_serverhttp_referer-empty/#findComment-504485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.