Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite breaks images on localhost

images are broken when viewing locally

         

JavaReb

5:06 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



Im experimenting with mod_rewrite and I want to disable other websites from embedding my images on their pages.

I have the following in the .htaccess file wihtin a directory called 'img'


RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?somesite.com/.*$ [NC]
RewriteRule \.(gif¦jpg¦png)$ http://www.somesite.com/nasty.gif [R,L]

Of course, ive changed the domain names, but when I view any of my pages locally, i get broken images.

What things could I be missing?

[edited to add:]
If I add this line, then images show up when viewing locally


RewriteCond %{HTTP_REFERER}!^http://localhost/.*$ [NC]

help / comments?

more questions to follow...

jdMorgan

5:32 pm on Mar 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaReb,

Welcome to WebmasterWorld!

That is in fact the correct solution.

You might also want to add [127.0.0.1...] (standard IP address of all localhost machines) to the exclusion list.

Jim