NO its nothing that complicated - because I am testing on my own 2 sites first to get the syntax right, before even thinking of trying something on an external site.
So this is my TEST scenario, using my own sites for the moment...
example1.org.uk - my first site with a link to site 2
example2.org.uk - my second site.
I want to ban anyone arriving at second site, if they have used a link on the first site.
I want to have two alternatives avaiable (for different situations)
1 - a customised landing page
or
2 - returning a 403 access denied
site 1 is example1.org.uk
site 2 is example2.org.uk
Yet, if I put this in the htaccess file for site 2, it doesn't stop me using a link in site 1 which takes me to site 2, and I was hoping it would.
this doesn't work
#Refer contains either, than deny access
RewriteCond %{HTTP_REFERER} (example1)
RewriteRule .*$ - [F]
and I am struggling to find out what the problem is.
It also doesn't work if I try and create a landing page version which directs to a landing page on site 2
#Refer contains either, than deny access
RewriteCond %{HTTP_REFERER} (example1)
RewriteCond %{REQUEST_URI} !^/landingpage\.php$
RewriteRule .* [
example2.org.uk...] [L]
I've remembered to include the intended landing page in my list of "not to be redirected" pages on site 2 using the ! expression - nearer the beginning of .htaccess than the Rewrite argument. that list works fine in conjunction with the other working Rewrite commands I use so I'm assuming the problem isnt there.
I've uploaded the landing page to example2.org.uk/landingpage.php
I've put the landing page in robots.txt as Disallow
The RewriteRule line works in other sections of the .htaccess
The RewriteCond rule works with source IP regex ranges, and with UserAgent terms
But this particular REFERER one won't work and its got me beat.
The log entry for example2.org.uk site logs which results from the failed command is this - perfectly normal
Source.I.P.address - - [29/Nov/2011:22:47:19 +0100] "GET /index.html HTTP/1.1" 200 12373 www.example1.org.uk "-" "user agent string" "-"
One other thing that did puzzle me - why is REFERER spelt with only one R in the middle? ( tried spelling it with two Rs but that didn't work either)
Picking up one other point mentioned above - yes - I do have a ban on blank user agents and it works fine for me giving a lot of unwanted stuff a 403