Web Hosting Talk







View Full Version : .htaccess Issue With Images In New Window


war59312
02-02-2006, 02:51 AM
Hello,

I am having a problem opening images in a new window which is created via javascript.

The problem is that I get a 403 error because my .htaccess file is blocking it from displaying the image correctly.

Here is example of what I use to display and open images in a new window when click:

<a href="javascript:void(0)" onclick="window.open('http://www.example.com/images/exampleBIG.png')">
<img src="http://www.example.com/images/exampleSmall.jpg" alt="Just An Example Image" /></a>

Here is the part of my .htaccess file that matters:

# Stop Leechers From Hotlinking Images And Files

Options +FollowSymLinks

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com(/)?.*$ [NC]
RewriteRule .*\.(torrent|iso|gif|jpe?g|avi|css|doc|mid|mov|mp3|mp4|mpg|pdf|pps|ppt|ra|ram|swf|wav|wma|xml|png|cab|7z|cmd|txt|log|rar|zip|exe|js|ex_|dll)$ - [F,NC]

Thanks a lot,

Will

Neoboffin
02-02-2006, 06:48 AM
I'm not sure, but you could try this one:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://yoursite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com/ [NC]
RewriteRule [^/]+.(torrent|iso|gif|jpeg|avi|css|doc|mid|mov|mp3|mp4|mpg)$ - [F]

Etc, you'll know how to finish it off.

war59312
02-05-2006, 04:59 AM
Hey,

I figured it out, thanks buddy. :)

Take Care,

Will