BiGDUG Posted November 14, 2006 Share Posted November 14, 2006 I am using a header to redirect users, if url contains certain elements then it will redirect them one way if not then they will simply go to the home page.I am using the following;[code]<?if($utm_source==="cj"){header('Location:'. $URL);}else{header('Location:index.php');}exit();?>[/code]The problem I have is that if any one goes to the site via the standard URL without the utm_source variable then it is not redirecting to index.php which is basically itself. It does work if you redirect to another page.What i need is if someone goes to www.bigdug.co.uk or www.bigdug.co.uk/index.php it simply continues to load the index page if the user goes via http://www.bigdug.co.uk/?utm_source=cj&URL=http%3A%2F%2Fwww%2Ebigdug%2Eco%2Euk%2Facatalog%2FBudget%2Ehtmlit redirect to the URL as set in variable URL.Many thanksMark Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/ Share on other sites More sharing options...
The Little Guy Posted November 14, 2006 Share Posted November 14, 2006 use $_GET[''][code]<?phpif($_GET['utm_source']=="cj"){header('Location:'. $URL);}else{header('Location:index.php');}exit();?>[/code] Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/#findComment-124527 Share on other sites More sharing options...
trq Posted November 14, 2006 Share Posted November 14, 2006 Then all you really need is....[code]<?phpif($_GET['utm_source'] == "cj"){header('Location:'. $URL);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/#findComment-124530 Share on other sites More sharing options...
Orio Posted November 14, 2006 Share Posted November 14, 2006 Should be-[code]<?phpif($_GET['utm_source']=="cj") header('Location:'. $_GET['URL']);else header('Location:index.php');exit();?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/#findComment-124531 Share on other sites More sharing options...
Psycho Posted November 14, 2006 Share Posted November 14, 2006 Unless, I am misunderstanding you, the code above is in the index page. If that is the case there is a big problem because the page would just continue reloading itself indefinitely if $utm_source does not equal "ct". Plus you should have some error checking to ensure that URL has a value as well.[code]<?php$utm = (isset($_GET[utm_source]))?$_GET[utm_source]:"";$url = (isset($_GET[URL]))?$_GET[URL]:"";if($utm==="cj" && $url) { header('Location:'. $URL);}//Show standard index page content?>[/code] Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/#findComment-124532 Share on other sites More sharing options...
BiGDUG Posted November 14, 2006 Author Share Posted November 14, 2006 Excellent thanks for that!! Link to comment https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/#findComment-124557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.