jhollin1138 Posted March 21, 2005 Posted March 21, 2005 I am interested in using Hotlink, or something, to prevent information in some folders of my web-space from being used by others. I only want to be selective on the folders I am protecting and not everything. Is there some simple way to do it? Quote
TCH-Andy Posted March 21, 2005 Posted March 21, 2005 Do you want to prevent all access to most people? (in which case you can password protect those folders) If it's just graphics being hotlinked in come folders, then you can edit the .htaccess in those folders see guide to hotlink protection for details. Quote
jhollin1138 Posted March 21, 2005 Author Posted March 21, 2005 Do you want to prevent all access to most people? (in which case you can password protect those folders) If it's just graphics being hotlinked in come folders, then you can edit the .htaccess in those folders see guide to hotlink protection for details. <{POST_SNAPBACK}> It is just the images in some folders. I'll have a look at .htaccess, thanks. Password protecting a folder, I can use that too for something else. Now how do I do that? Quote
TCH-Bruce Posted March 21, 2005 Posted March 21, 2005 Jim, you can set hotlink protection and password protection right through cPanel. For your image folder select HotLink protection and enter the urls you will allow to link to your images. For password protection select Web Protect in cPanel and you will be given a list of folders you can select from. Select one of the folders and you will be directed to a screen to add users and passwords. Quote
jhollin1138 Posted March 21, 2005 Author Posted March 21, 2005 Jim, you can set hotlink protection and password protection right through cPanel. For your image folder select HotLink protection and enter the urls you will allow to link to your images. For password protection select Web Protect in cPanel and you will be given a list of folders you can select from. Select one of the folders and you will be directed to a screen to add users and passwords. <{POST_SNAPBACK}> Thanks, I'll look there too. Quote
jhollin1138 Posted March 21, 2005 Author Posted March 21, 2005 For your image folder select HotLink protection and enter the urls you will allow to link to your images.<{POST_SNAPBACK}> Is there a way exclude certain folders from HotLink? For example let's say I have a folder I use to post images to the various forums I visit. It would be to much of a pain to add each URL to the list each time I want to post to a new forum. It would be much easier if I could just un-HotLink a folder. Can you do this? Quote
Guest helpbytes Posted March 21, 2005 Posted March 21, 2005 (edited) For your image folder select HotLink protection and enter the urls you will allow to link to your images.<{POST_SNAPBACK}> Is there a way exclude certain folders from HotLink? For example let's say I have a folder I use to post images to the various forums I visit. It would be to much of a pain to add each URL to the list each time I want to post to a new forum. It would be much easier if I could just un-HotLink a folder. Can you do this? <{POST_SNAPBACK}> You could override the rule in the folder, create a htaccess in the folder, that lets everything access the images, the htaccess in a folder takes priority over the previous ones. You can also do it in the main htaccess, something like: RewriteCond %{REQUEST_URI} !^/foldername/* I have this on my website, so that i can put some small images in a folder that people can use to link to me. I should probably note this wont work using the cpanel hotlink prevention manager thingy, I edit the htaccess myself so I can have a more accurate rule set. My .htaccess section for hotlink looks like this: >#Hotlink Protection RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.|forum\.|gdb\.|besecure\.)?helpbytes.co.uk.*$ [NC] RewriteCond %{REQUEST_URI} !^/images/bandwidth-free/*$ [NC] RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|png|PNG)$ http://www.helpbytes.co.uk/bandwidthProtection.php?file=%{REQUEST_URI} My code redirects these requests to a php file, which simply logs the referer so I can chase them up on it, and then sends a forbidden(403) header. Edited March 21, 2005 by helpbytes Quote
jhollin1138 Posted March 21, 2005 Author Posted March 21, 2005 @helpbytes: Thanks so much. What can I say am a "htaccess" noob. So if I am reading your post correctly, if I put a "htaccess" file (that I have formated correctly) into a directory, it will affect the subdirectories as well? In addition, placing a "htaccess" into a subdirectory will "override" the "htaccess" of its parent directory? Also, care to share your "php" script? Quote
Guest helpbytes Posted March 21, 2005 Posted March 21, 2005 So if I am reading your post correctly, if I put a "htaccess" file (that I have formated correctly) into a directory, it will affect the subdirectories as well? In addition, placing a "htaccess" into a subdirectory will "override" the "htaccess" of its parent directory?Yes, thats true. Also, care to share your "php" script? You don't need to use any script, you can simply make the rule this: RewriteRule .* - [F,L] Which sends a forbidden response. I use a script, just so I can see which websites are hotlinking. My PHP script looks like this: ><?PHP $filePath = '/home/helpbyt/public_html/bandwidthThiefs.txt'; $string = $_GET['file'] . "\t" . getenv('HTTP_REFERER')."\r\n"; $fp = @fopen($filePath,'a'); @fwrite($fp,$string); @fclose($fp); header('403 Forbidden'); ?> The filePath would obviously have to reflect your own path, and would need permissions of 777 so it can be written to. Each occasion of hotlinking adds a line, with the file they're linking to, a tab, and the website linking. Quote
jhollin1138 Posted March 22, 2005 Author Posted March 22, 2005 @helpbytes: Thanks allot. I think now I understand what I really need to do to HotLink only a few directories. Plus, as an added bonus, you have given me a way to track who is trying to use "my stuff." Quote
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.