Jump to content

Redirecting people using PHP - problems


BiGDUG

Recommended Posts

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%2Ehtml

it redirect to the URL as set in variable URL.

Many thanks
Mark
Link to comment
https://forums.phpfreaks.com/topic/27236-redirecting-people-using-php-problems/
Share on other sites

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.