Topic: Content based on referer?
I've been playing with referrers on localhost somewhat unsuccessfully but have the following working on two test domains. I'm trying to show different content based on the referer, so anyone finding my site through any other means than fluxbb/punbb.org will see my normal portfolio site. Those coming from flux/pun will see my skins/mods etc.
<?php
$match = false;
$sites = array("fluxbb.org", "mynormalsite.com");
if(strlen($_SERVER['HTTP_REFERER']))
{
$referer = parse_url($_SERVER['HTTP_REFERER']);
$referer['host'] = str_replace("www.", "", strtolower($referer['host']));
$match = in_array($referer['host'], $sites);
}
if($match)
{
?>
<html>
<head>
<title>My FluxBB Portfolio</title>
</head>
<body>
<p>Welcome FluxBB user! Here you can find my skins and mods free to download.</p>
</body>
</html>
<?php
}
else
{
?>
<html>
<head>
<title>My Non-FluxBB/PunBB Related Stuff</title>
</head>
<body>
<p>Welcome to my portfolio of non-fluxbb related things.</p>
</body>
</html>
<?php
}
?>I'm looking to throw a third site into the array so that users coming from PunBB will see my "PunBB mods" page, whereas users coming from FluxBB will see my "FluxBB mods" page. If the referrer is blank or doesnt match fluxbb.org/punbb.org it should just show my normal site.
If someone can code up a basic working example with a third site loaded in the array (and a seperate third html sheet) I'd be glad to shoot over some beer money through paypal. Cheers ![]()