Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ - [F]
Be sure to replace "mydomain.com" with your own. The above code causes a broken image to be displayed when its hot linked.
Welcome to WebmasterWorld!
> i need to prevent Specific site from linking my pics.
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.com [NC]
RewriteRule \.(gif¦jpg)$ - [F]
Also, replace the broken pipe "¦" character with a solid pipe before use.
Jim
That depends on whether you have eight sites or eight subdirectories.
The simplest way is to put the code in the .htaccess file of the directory above the subdirectories where the images are stored. Or you can put a copy of the code in each image subdirectory, if the site has a lot of non-image content; this will slightly improve server efficiency.
An .htaccess file will affect requests for all resources in the same directory as the .htaccess file, and all subdirectories of that directory.
Jim
so if my images are in
www.mysite.com/images/jpg/
then .htaccess file shoud
www.mysite.com/images/jpg/.htaccess
and in .htaccess is this
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://www.badsite.com [NC]
RewriteCond %{HTTP_REFERER} ^http://badsite.com [NC]
RewriteRule \.(gif¦jpg)$ - [F]
I just want to confirm this...
Then the site (badsite.com will be prevented of using my pics..?
Place this in www.mysite.com/images/jpg/.htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.com [NC]
RewriteRule \.(gif¦jpg)$ - [F]
Flush your browser cache before testing any change to your access control code; Images fetched from local browser caches cannot be affected by server-side access controls until those cached entries expire.
Jim
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.org [NC]
RewriteRule \.(gif¦jpg)$ [mysite.com...] [R,L]
The following is much more efficient, and blocks three sites:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.org [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite2\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite3\.net [NC]
RewriteRule \.(gif¦jpg)$ /FO.jpg [L]
Jim