Jump to content

Redirect Based On Refer website


mikem562

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. :)

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.