JohnnyDoomo Posted September 6, 2016 Share Posted September 6, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302093-hotlink-protect-sub-directories-but-not-main-dynamically-created-folder/ Share on other sites More sharing options...
requinix Posted September 7, 2016 Share Posted September 7, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/302093-hotlink-protect-sub-directories-but-not-main-dynamically-created-folder/#findComment-1537130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.