Forum Moderators: phranque
If your site is on an Apache server && if you are allowed to use .htaccess files && if mod_rewrite is enabled you could use this:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?referringdomain\.tld/ [NC]
RewriteRule .* http://example.com/anotherpage.html [R,L]
..where 'referringdomain.tld' should be changed in the name of the referring domain and the URL in the RewriteRule should be altered in the address of the page you want them to be redirected to.
You should realise however that there's a growing amount of users who's browsers or proxy servers or other security software don't send a referer. So there's a percentage of users that come from the referring URL but are not redirected.
These lines did the job! I'm aware of holes in it (proxys), but diverting others is good enough (I'm sure the procent of proxy users is much smaller than other ones).
Now, is there a way to divert ALL referers except my site (I have three servers, two of them have only files, and I'd like to protect them) or chosen domains?
Another thing, just to make it clear for me. If I put this .htaccess in 2. level folder, it will affect all folders from 2. on, and not on 1st right?
Cheers;)