Forum Moderators: not2easy
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ http://www.mydomain.com/nasty.gif [R,L]
My question is this, If I change nasty.gif to index.html will it cause the browser to serve up my homepage if I have the following script in my head tag for index.html.
if (window!= top)
top.location.href=location.href
I know this script will prevent sites from framing my site as I have tested it. Also if anyone has any comments on using this script for preventing framing please post them.
Welcome to WebmasterWorld [webmasterworld.com]!
Unfortunately, browsers will not properly follow a redirect from an image-format file to an html-format file; all you'll get is a "broken image" graphic where the original hotlinked image was.
The two methods that will work are replacing the image, as the code you posted does, or simply returning a 403-Forbidden response as shown below, which again shows the "broken image" graphic, but places less load on your server.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com/ [NC]
RewriteRule \.(gif¦jpg)$ - [F]
HTH,
Jim