Jump to content

Archived

This topic is now archived and is closed to further replies.

Gutspiller

htaccess to block images called by watermark.php?

Recommended Posts

The script works fine by itself, but calls medium and fullsize images through a watermark.php file, but not thumbnails. I want to keep the thumbnails hotlinkable while blocking the medium and fullsize images that are called through this watermark.php file. Is there a way to have a htaccess block the hotlinking of images from my site that are called through this watermark.php file? I tried this:

[code]

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png|php|PHP)$ http://www.domain.com/images/banners/hotlinker.gif [L]

[/code]

But it didn't work and still allows images to be hotlinked. Any ideas?

(I don't know enough programming to tell the script to store the images in different directories than the thumbs so that won't work)

EDIT: The medium size url looks like this: [a href=\"http://www.domain.com/images/watermark.php?file=107&size=1\" target=\"_blank\"]http://www.domain.com/images/watermark.php?file=107&size=1[/a]

and the fullsize image url looks like this: [a href=\"http://www.domain.com/images/watermark.php?file=107\" target=\"_blank\"]http://www.domain.com/images/watermark.php?file=107[/a]

Share this post


Link to post
Share on other sites
First, you shouldn't use this to prevent hotlinking since some firewalls, some user-agents (browsers) may block or not send or modify the HTTP_REFERER header so it's not a reliable thing.

Instead, you should make watermark.php itself restrict these bigger images from being hotlinked.

Share this post


Link to post
Share on other sites
It's someone elses script and I don't know coding. Getting an htaccess to block php hotlinking seems (if possible) to be the easiest way for me to get this accomplished.

Does anybody know how to get the htaccess to block php hotlinking?

Share this post


Link to post
Share on other sites
I found these two resources, but I don't know enough to change them to fit my site:

[a href=\"http://www.vbulletin.org/forum/showthread.php?p=609945\" target=\"_blank\"]http://www.vbulletin.org/forum/showthread.php?p=609945[/a]
[a href=\"http://forums.invisionpower.com/lofiversion/index.php/t191265.html\" target=\"_blank\"]http://forums.invisionpower.com/lofiversio...hp/t191265.html[/a]

Can somebody please help me sort out a working version of the htaccess that will block a watermark.php file?

EDIT: I also tried this that I was given by someone else and it didn't work either:

[code]
SetEnvIfNoCase Referer "^http://www.yourdomain.net/" allowed=1
SetEnvIfNoCase Referer "^http://yourdomain.net/" allowed=1
SetEnvIfNoCase Referer "^$" allowed=1

Order Allow,Deny
Allow from env=allowed

<Files "*.php">
Order Allow,Deny
Deny from all
</Files>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.