Finally… after ages of looking around I found the fix for something we were trying to do for our business facebook adverts. We basically wanted to refer all vistors who come from our facebook adverts to a specific special offers page (facebook.php) Find a quote below of how to do it

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://([^.]+\.)*(facebook)\.com
RewriteRule ^$ facebook.php [R=302,L]

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

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.

       Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
Trackback

only 1 comment until now

  1. The power of the htaccess file is unlimited when it comes to redirecting… not to mention mod_rewriting for urls.

Add your comment now