Jump to content

Hotlink protect sub directories, but not main dynamically created folder?


Recommended Posts

My image gallery creates folders that look like this:

 

thumbnail: http://blah.com/data/99999/thumbs/abc.jpg

medium: http://blah.com/data/99999/medium/abc.jpg

original: http://blah.com/data/99999/abc.jpg

 

The script dynamically creates new folder IDs where the "99999" are. I would like the .htaccess file to allow the /thumbs/ and /medium/ folders to always allow hotlinking, but I want to protect the fullsize image and replace it with the medium image if it's ever coming from a domain other than my blah.com.

 

I cannot create an htaccess file for every ID folder, so I need an htaccess rule that wildcards the ID folder, and sits in /data/.

 

Can anybody help with the code required to do this? Or is something like this not possible until I get the fullsized images OUTSIDE of the folder where the thumbnails, and medium sized images are?

 

I have very little knowledge of htaccess, so the exact code I can paste is greatly appreciated.

 

Thanks for any help you can provide.

The RewriteRule is pretty straightforward (replace /data/X/Y with /data/X/medium/Y), so the "hotlinking" portion you're missing is the RewriteCond immediately preceding it.

RewriteCond %{HTTP_REFERER} !^https?://blah\.com(/|$)
But... are you creating actual directories there? That's really not the right way to do things. There's no problem making it look like there's directories there, but on the server there should most definitely not be tons of directories in /data. For a variety of reasons, not least plummeting performance the more you make.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.