Forum Moderators: phranque
# Block foreign referrers
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://www\.yoursite/ [NC]
RewriteRule .* - [F]
This works perfectly but there is one drawback, it also re-directs sites which are linking to my index page. Is it possible to allow linking to my main index page only, and re-direct all attempts to link to pages within my site to my custom error page?
Thanks in advance.
# Block foreign referrers
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.yoursite/ [NC]
RewriteRule . - [F]
RewriteRule [^/]+ - [F]
Jim
I tried the changes you suggested. When I checked a couple of sites which link to my main page I got error message "you do not have permission to enter mysite.com/index.html
The sites are linking to mysite.com and not specifically to the index page.
Any further suggestions would be appreciated.
> if you just use "domain.com/" as the link to your index page, and don't call it specifically by "domain.com/index.htm" or "domain.com/index.php", then the following should work.
That's the problem. So you'll have to add a RewriteCond:
# Block foreign referrers
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.html$
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://www\.yoursite/ [NC]
RewriteRule . - [F]
Jim