Display a page on your website for known referrers Print
By Patrick LEFÈVRE published on 2012 02 09
Version française disponible ici
You are a very good webdesigner and you have lots of clients. That’s fine. Now imagine that lots of these websites have a commun theme about the same kind of business activity.
For marketing reason, you want to display on your own site a specific page when visitors click on your web address shown on the footer of these client sites.
So, how to accomplish this redirection, depending of your referrers in a minimum of work without the need to change all inbound Urls?
Statistic sofwares can be a good inspiration: a PHP global variable retrives the inbound link referrers.
Based on this fact, these lines of code can be added in a form named “referrers”:
<txp:php>/**** @script: grab referrer domains from a list and redirect to a specific page**** @author: Patrick LEFEVRE <patrick[dot]lefevre[at]gmail[dot]com>** @date: 12/09/2010** @revision: 04/02/2012** @version 2**/// grab referrers$ref = @$_SERVER['HTTP_REFERER'];// sanitize Urlsif(!empty($ref)){$ref = str_replace('www.', '', parse_url($ref));// List of external Urls$s[0] = 'pixar.com';$s[1] = 'disney.fr';$s[2] = 'dreamworks.com';$s[3] = 'macguff.com';// if an Url is listed, serve a specific page, otherwise display the main oneif (in_array($ref['host'], $s)) {header('Location: '.hu.'we-create-websites-for-animation-studios-industry');}else{header('Location: '.hu.'en');}}</txp:php>
Comments: $_SERVER['HTTP_REFERER'] grab the inbound link.
Then, this Url is sanitized in order to remove “www” characters to keep the domain even in complex schemes (see parse_url).
Your client domain names are stored into $s[] (an array).
We compare inbound link with the client domain list, then we redirect to the page or another one.
You need to change your website structure, remove all the “default” template content and add in it only this:
<txp:output_form form="referrers" />
Now put all your nain content page into a new template associated to a section (i.e “en”).
Note. This article’s subject had been adapted into a plugin available here: pat_referrers.
Related Articles
Hide your sections for non admin users - Publié le 2011.09.28 By Patrick LEFÈVRE.
Control you blank pages - Publié le 2011.12.22 By Patrick LEFÈVRE.
Your comment forms in French or any other languages - Publié le 2011.12.24 By Patrick LEFÈVRE.
Pat_tile, a plugin for your articles title - Publié le 2013.04.26 By Patrick LEFÈVRE.
Split your links list into columns - Publié le 2011.12.14 By Patrick LEFÈVRE.
Access to all article archives
