Forum Moderators: phranque

Message Too Old, No Replies

Blocking Remote Linking of Images

How can this be done?

         

Johnathan

5:19 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



So i tried the below method to prevent remote linking of my sites images. And it does work.. But i have one problem with it and thats my question..

everytime i reload a page on my site (since this has been installed) the releoad makes all my images dead.. In other words reloading messes up my entire page.. I'm guessing its somethign to with cache? but i was wodnering if theres somethin i can add to the .htaccess file that would allow me to reload the page and have it still show my images..

only do i think i will want to use this method.

any ideas? thanks.


1) Open a text editor
2) Cut and paste:
RewriteCond %{HTTP_REFERER}!^http://yoursite.com/ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.yoursite.com/ [NC]
RewriteRule [^/]+.(gif¦jpg)$ - [F]
3) change yoursite.com as appropriate
4) save as .htaccess
5) upload to your images folder
6) check your site and make sure it still works :)

keyplyr

6:45 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That code never worked for me either, although I do read that it does work for others.

If in fact it is a cache issue, then this may help (put in the <HEAD> section)

<meta http-equiv="Pragma" content="no-cache">

keyplyr

8:39 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




BTW - try adding this to the top of that code:

RewriteEngine on

...and replace the broken pipe between gif and jpg (gif¦jpg) . They screw up at this forum so you can't cut and paste. It should be solid.

Johnathan

10:39 pm on Apr 20, 2003 (gmt 0)

10+ Year Member



neither of those worked for me

thank you though.

jdMorgan

10:53 pm on Apr 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Johnathan,

In many cases a referrer is not passed with the request, and this could be your reload problem. Try:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com/
RewriteRule \.(gif¦jpg)$ - [F]

The first RewriteCond will allow blank referrers. The second line replaces the first two lines of the original, with additional corrections.

As noted, the broken vertical pipe "¦" must be changed to a solid vertical pipe before use. If this does not work, please consider providing a snippet from your site's error log, to clarify the problem.

HTH,
Jim