mikem562 Posted September 27, 2011 Share Posted September 27, 2011 Hello, This is what I'm trying to-do. I have an index.php file I would like a bit of code that says "If you got here from www.websitea.com (or a link within that site) OR www.websiteb.com" do this : else do this: I'm just not sure how to check where they're coming from. so basically if your on google.ca and you goto the site it will exicute the else part of the code but if your already on sitea or b and you click a link it will not Quote Link to comment https://forums.phpfreaks.com/topic/247972-redirect-based-on-refer-website/ Share on other sites More sharing options...
mikem562 Posted September 27, 2011 Author Share Posted September 27, 2011 I found this which I think is what I'm looking for (or something similar) if( (strpos($_SERVER['HTTP_REFERER'], get_bloginfo('home')) === false) && !$_SERVER['QUERY_STRING']) but I'm not sure how to make it, if www.sitea.com = false or siteb.com = false & your not coming from within the site itself then ... else etc Quote Link to comment https://forums.phpfreaks.com/topic/247972-redirect-based-on-refer-website/#findComment-1273326 Share on other sites More sharing options...
NLCJ Posted September 27, 2011 Share Posted September 27, 2011 if($_SERVER['HTTP_REFERER'] == "http://www.google.com/") { //Your code } Quote Link to comment https://forums.phpfreaks.com/topic/247972-redirect-based-on-refer-website/#findComment-1273331 Share on other sites More sharing options...
mikem562 Posted September 27, 2011 Author Share Posted September 27, 2011 perfect thank you!, how would I add more then 1 url to that so if google -or- if this -or- if this, etc Quote Link to comment https://forums.phpfreaks.com/topic/247972-redirect-based-on-refer-website/#findComment-1273332 Share on other sites More sharing options...
NLCJ Posted September 27, 2011 Share Posted September 27, 2011 I haven't tested it, you should before you start using it. For multiple sites: $sites = array("http://www.google.com/", "http://www.microsoft.com"); if(in_array($_SERVER['HTTP_REFERER']), $sites) { //Your code } Etcetera. Quote Link to comment https://forums.phpfreaks.com/topic/247972-redirect-based-on-refer-website/#findComment-1273333 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.