• Home
  • About
  • Contact
  • Disclaimer
  • Sitemap

Too Many Secrets

Feed on
Posts
Comments
« Mini site development - Part 1
sushirestaurants.com for sale at a good price »

How to redirect based on referer

Jul 3rd, 2008 by Richard

Have you ever wanted to redirect visitors to a special promo page based on how they were referred to your site?

You can enhance the visitor experience by checking the referer log for the visitor and then showing them a custom page that relates to the web site that referred them to you.

Why redirect visitors?

This is a good technique to use if you do advertising or link campaigns with other sites.

Let’s say that you took out an ad on Elliot’s blog and you wanted to direct any visitors who clicked on your ad to a special sales page.

On the sales page, you could include content thanking them for visiting from Elliot’s site, tell them about a special promotion for visitors referred by Elliot etc. It personalizes the whole process and makes the visitors feel appreciated.

And if they feel that their business is appreciated, they are more likely to buy your product.

The redirect code

Here is the code to check your web server referer and then redirect the visitor to your custom sales page. Simply take the two lines of code and put them in your .htaccess file and you’re done.

RewriteCond %{http_referer} ^http://([^.]+\.)*(elliotsblog)\.com
RewriteRule ^$ special.html [R=302,L]

In this example, we look for referer’s from elliotsblog.com and we direct them to a page on our site called special.html.

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

NOTE: You need to have the apache module mod_rewrite installed on your web server.

Enjoy !

Related Posts
  • Redirect lost traffic with one line of code
    My stats program gives me a list of 404 errors so I can easily see what pag...
  • Tax time for domainers?
    There is a lively discussion at Mike's blog today about taxes and domainers...

Posted in Web Hosting Tips

2 Responses to “How to redirect based on referer”

  1. on 03 Jul 2008 at 6:21 pm1Frank Michlick

    Good tip, however I am not quite sure why you would not point the ad directly to your special landing page directly, instead of adding a short delay with the direct. For tracking purposes all ad links should point to different URLs anyways.

    What is nice is that you can use similar code to redirect visitors based on other browser settings, i.e. the language their browser is set to.

    Thanks for sharing,
    /FM

  2. on 03 Jul 2008 at 6:28 pm2Richard

    @Frank

    The handy thing about using the referer for the redirect is that if you also have text links from the site, you can redirect them as well.

    For example, perhaps you run a banner ad on a blog and the blog owner also writes a post mentioning your site and gives you a backlink to the main page of your site, with the referer redirect, you can capture the visitors who come from the blog post as well.

  • Latest Posts

    • Rank using an anchor text keyword matrix
    • Domainers can learn from Beijing Olympics
    • How to fix Bido
    • Tax time for domainers?
    • Block bad bots from your site
  • Categories

    • Domaining (5)
    • Funny Stories (1)
    • Reviews (2)
    • Web Hosting Tips (9)
    • Web Site Development (5)
  • Popular Posts

    • How to redirect based on referer
    • Fix your wordpress permalink structure
    • Avoid wordpress duplicate content
    • Domainers have a bad reputation
    • Block bad bots from your site

Too Many Secrets © 2008 All Rights Reserved.