Jump to content

Referring URL redirect


JonEMD

Recommended Posts

Hello People,

 

I've been racking my brains, searching google and trawling through the many pages here to see if someone else has already asked the same question but I cant find it.

 

I'm trying to build a simple redirect script based on the referring URL.

 

I want to direct the user to "page a" if any of the arrays are found and "page b" if not.

 

This is what I have so far

 

<?php 

$main_string="@$HTTP_REFERER";

$arr = array('aaaa','bbbb','cccc');

foreach($arr as $key => $search_needle) {

if(stristr($main_string, $search_needle) != FALSE) 
{
echo "<meta http-equiv=Refresh content=0;url=http://www.google.com/PAGEA.html>";
}
} 

?>

 

I thought that it might be a case of adding the "else" command but doing that will always redirect to "page b" if all of the arrays aren't true and only 1 needs to be.

 

Anyone got any ideas?

 

Thanks

Link to comment
Share on other sites

That makes sense but I'm not sure what to do with it.....

 

Currently, if any of the arrays match it goes to "page a" which is fine. The issue I have is if none of the arrays match nothing happens but I want it to redirect to "page b".

 

How can i code that? What function would I need to use?

 

Thanks

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.