Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://mysite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http:De//www.mysite.com.*$ [NC]
RewriteRule .*.(gif¦GIF¦jpg¦JPG)$ - [F]
but i also want to stop a few sites (some i don't know about) from doing this:
<img src="http://mysite.com/" width="1" height="1">
and adding to my bandwidth.
I do know how to stop domains with certain keywords:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} "cartoon" [OR]
RewriteCond %{HTTP_REFERER} "movies"
RewriteRule .* http://redirecthere.com [L]
but is there a way to stop all other sites and redirect them?
(this doesnt work)
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://mysite.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com.*$ [NC]
RewriteRule .* http://redirecthere.com [L]
[edited by: jdMorgan at 2:37 am (utc) on Nov. 24, 2003]
[edit reason] De-linked URLs [/edit]
You have to use an external redirect if you want to send them off to another site. Fixing that, as well as combining your two RewriteConds into one, gives:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.*$ [NC]
RewriteRule .* http://redirecthere.com [R=301,L]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.*$ [NC]
RewriteRule .* - [F]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.*$ [NC]
RewriteRule!^my_custom_403_page\.html$ - [F]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite.com.*$ [NC]
RewriteRule!^my_custom_403_page\.html$ - [F]