Reputation: 2824
I am trying to write a php script for following...
if country = in or ca
redirect_to http://example.com
else redirect to http://example2.com
if $_GET['foo'] = 'bar' and country = in or ca
redirect to http://example3.com
else redirect to example.com
else redirect to example.com
and I have tried following...
$country = $_SESSION['countrycode'];
//if country india,canada
if($country == 'in' || $country == 'ca') redirect_to('http://example.com/');
else redirect_to('http://example2.com/');
//if querysting contains foo=bar and country india,canada
if($_GET['foo'] == 'bar'){
if($country == 'in' || $country == 'ca') redirect_to('http://example3.com/');
else redirect_to('http://example.com/');
}
else redirect_to('http://example.com/');
But its not working in case of query string foo = bar. Please suggest.
Upvotes: 1
Views: 79
Reputation: 504
Your first conditional statement is redirecting the page away from this script. The second conditional statement is never read. Instead, you should refactor something like this:
if($country == 'in' || $country == 'ca'){
if($_GET['foo'] === 'bar')
header('Location: ' . $urlof3);
else
header('Location: '. $urlof2);
}
Cheers
Upvotes: 2