Web Hosting Talk







View Full Version : Alternative to cPanel's Hotlink Protection?


vito
01-31-2003, 09:31 AM
Given that cPanel's Hotlink Protection feature has been "broken" for some time and there is no timeline on when it will be fixed, I'm looking for alternate solutions.

I looked for quite a bit on sites like Hotscripts, Scriptsearch, etc. I can't believe there isn't some script somewhere that I can use to prevent hotlinking. I'm not talking about protecting my images. I'm referring to keeping people from directly linking to an htm page on my site from another site.

Any suggestions?

Vito

The Prohacker
01-31-2003, 01:00 PM
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - [F]

vito
01-31-2003, 01:01 PM
Thanks, ProHacker.
Unfortunately, I am just a reseller. I do not have root access... :(

Vito

The Prohacker
01-31-2003, 01:10 PM
You don't need root..

Just alter the domain to fit your site, and put it in an .htaccess inside the folder you wish to protect, if you wish to protect and entire site put it in your web root directory, public_html..

vito
01-31-2003, 01:24 PM
ProHacker, I appreciate you taking the time to help out.
Please let me see if I got this straight:

In a text editor, create a .htaccess file that contains:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !
http://mysite.com/directory/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/directory/.*$ [NC]
RewriteRule .*\.(htm|swf)$ - [F]

where the htm and swf files in directory are the ones I'd like to protect.

Then I just upload the .htaccess file into the directory, and that's it? Then when a visitor comes on my site, he will be able to freely view all the pages in the directory, but if he tries to hotlink to them from his site, he will not be able to?

Soryy, I'm not big in programming, so I still need my hand held on occasion... :blush:

Vito

The Prohacker
01-31-2003, 01:28 PM
It would need to be like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
RewriteRule .*\.(swf|htm)$ - [F]


And yes you put this into an .htaccess file and put it in that directory you wish to protect.

Now, I'm kind of wondering why you want to protect .htm files, this would only stop things like iframes, and not direct leeches of the file, because the .htaccess will allow showing of files with no referer incase someone just opens the image directly in a new window..

vito
01-31-2003, 01:36 PM
I am finding that some people (not many, thankfully) are hotlinking directly to the tutorial product on my site. And I have to spend my time chasing them down. Not my idea of getting the most productivity out of my day. :mad:

All the files on my site are either html or php. With the exception of my tutorials which are htm (and of course their corresponding swf files). So I still want my site visitors to freely view the movies without restriction, but I want to prevent others from hotlinking directly to the htm files.

Vito