Jump to content

Recommended Posts

Posted

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?

Posted
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.

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?

Posted

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.

Posted
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.

Thanks, I'll look there too. :wallbash:

Posted
For your image folder select HotLink protection and enter the urls you will allow to link to your images.

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?

Guest helpbytes
Posted (edited)
For your image folder select HotLink protection and enter the urls you will allow to link to your images.

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?

 

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 by helpbytes
Posted

@helpbytes: Thanks so much. What can I say am a "htaccess" noob. :P

 

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?

Guest helpbytes
Posted
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.

Posted

@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." :) :)

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...