Redirect users based on referrer

Posted: January 30th, 2012 | Author: | Filed under: User Experience | No Comments »

Redirecting visitors from certain referrals may seem a little “black-hat” however it’s ethical and it’s a great way to offer special promotions to certain users from certain websites. Have you ever took out an advert on a website and wanted to direct those users to certain pages? It’s easy so let me explain.

Imagine personalising the users experience, they may well purchase your product based around variables that make them feel cosy because the visitor thinks they’re getting special treatment for coming to you from certain websites.

By doing this, you can enhance the visitors experience by referencing the referral on your custom page. Perhaps offering a promotion based on where visitors have come from. For instance, if you’re on Freeindex you may wish to refer customers to a special promotions page and it is this tutorial I’ll show you how to do this.

Okay, now I’ve sold this idea to you, let me give you the redirect code. You need the Apache Module mod_rewrite installed on your server.

Take the two lines of code below and place them in you .htaccess file and you’re done!

RewriteCond %{http_refer} ^http://([^.]+\.)*(freeindex)\.com
RewriteRule ^$ special-promotion.php [R=302,L]

In this example, I use FreeIndex being the referral website and we direct them to a page called special-promotion.php

You should change the domain and the page to anything you wish.

Need help implementing this? Check out my Web Development fees.

Brian Martin



Leave a Reply