PDA

View Full Version : Detect REFERER and redirect accordingly


Areku
02-11-2003, 09:59 AM
Hi!

I'd need a php routine to be implemented onto index.php so if a user DOES NOT come from a specific URL, it will be redirected to a DISCLAIMER first.

I guess this will have to be based on the REFERER variables.

If there's no workaround, all empty referers should be allowed to enter. Only those providing referer info and NOT matching the specific URL should be redirected to the disclaimer page.

Can any1 help?

I'd need the whole function and call coz I don't have many PHP experience.

Thanks!

GSHelpBoy
02-11-2003, 06:47 PM
<?php
$prev_page = 'page.php';
$disc_page = 'disclaimer.php';

if (strstr($_SERVER['HTTP_REFERER'], $prev_page)) {
// display page
} else {
// forward to disclaimer
header('Location: ' . $disc_page);
exit;
}
?>

filth_?_boy
02-11-2003, 06:50 PM
i have no skill but i'm sure i've seen it done like

<?php

if ($_SERVER['HTTP_REFERER'] == 'http://site.com') {
header("Location: http://www.site.com/disclaimer.php");
}
else {
header("Location: http://www.site.com/index.php");
}

exit;
?>

Areku
02-11-2003, 06:57 PM
Thanks SO much guys!