Not always you will be in this situation, where you don’t want people to visit your site (that come from certain site). Because usually everybody wants traffic to their site, the more the better.
But last week I was in an awkward situation where I didn’t want traffic that came from certain domain name. Regular readers of my blog already know this, I had sold one of my sites to someone (don’t want to mention his particulars out of respect). I had forgot to remove my personal information from the website.
Basically the site contained an introductory text that said “this is my project, purpose of the project, my name and my other sites”. Unfortunately, the new owner didn’t want to remove the info, and tried to push adware to the people who wanted to download free icons.
Obviously, I was furious, and sent numerous emails to him. At the end, he removed my particulars. But during this one week time, much damage was done (especially to my reputation). I had received emails telling me that I had cheated them, instead of giving them free icons I pushed them adware… basically, dissatisfied users! And they thought I am doing all these. That was the worst part. So I had to do something.
So, one of the solutions before the new owner removed my personal info was to redirect the traffic that was coming from this website to a particular page. A page that contained all the info and explained the user that the site was sold and no longer belonged to me. I also explained that it was unfortunate that the new owner took this direction for the new site. Lastly, I provided a direct download link to the free icons.
So how this is done? This redirection is done through .htaccess.
Redirecting users that come from certain URL to another
Here is the main code that should be put in your .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} referrerURL\.com/
RewriteRule ^$ www.redirectedURL.com [R=301,L]
Now let’s do some explanation.
This code RewriteCond %{HTTP_REFERER} referrerURL\.com/ detects the traffics that come from different websites. If the traffic comes from referrer dot com then the second command is true:
Second command says RewriteRule ^$ www.redirectedURL.com [R=301,L]
, i.e if the previous command is true then redirect the traffic to www.redirectedURL.com. Please note that you can be specific about this, you can even point it to specific page eg: www.redirectedURL.com/specific_page.html etc.
Conclusion
I hope you won’t be in this situation, but if you do then remember that there is a solution for it. At least temporary one.
For more tips sign up for my RSS.