Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 02-06-2010, 05:32 PM
Junior Member
 
Join Date: 02-06-10
Posts: 3
iTrader: 0 / 0%
.htaccess image hotlink protection not working

I'm trying to put a stop to image hijacking with the following .htaccess code, but I can't figure out why it won't work .

I've tried placing the file in the root directory and the actual image directory, and neither work. Strangely, I've tested other rewrite rules, and they work fine (non-www to www addresss, for example).

I've tested by using free hotlink checkers and by trying to hotlink from my other domains, and been sure to clear cache on each test. No luck making it work though.

Am I missing something?

Edit: I just tried on a different domain, and the code below is blocking www hotlinking, but not when the www is not used to link to the image.

Code:
RewriteEngine on RewriteCond %{HTTP_REFERER} . RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC] RewriteRule \.(jpe?g|png|gif)$ - [NC,F]

Last edited by dombrorj; 02-06-2010 at 05:47 PM.
 
Reply With Quote
  #2 (permalink)  
Old 02-06-2010, 05:51 PM
drmike's Avatar
Contributing Member
 
Join Date: 01-22-10
Location: Charlotte, NC
Posts: 1,745
iTrader: 0 / 0%
I used this tool:

http://www.htaccesstools.com/hotlink-protection/

And this is what I came up with:

Code:
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
That goes in root by the way.

Please note the change in the use of https. I'm kind of wondering about your code considering that. My understanding is with the s in there like you have it, it'll only work with a secure connection while mine makes it optional.

I hate htaccess rules though and have no idea what I'm doing. What why I used the formentioned tool.
 
Reply With Quote
  #3 (permalink)  
Old 02-07-2010, 07:08 AM
Junior Member
 
Join Date: 02-06-10
Posts: 3
iTrader: 0 / 0%
Thanks drmike,

Unfortunately, that didn't work either. I used a number of combinations from various online tools like the one you mentioned, and can't seem to get any of them to work.

There must be something else going on with my Apache server or something. Just can't put my finger on it.
 
Reply With Quote
  #4 (permalink)  
Old 02-07-2010, 07:10 AM
drmike's Avatar
Contributing Member
 
Join Date: 01-22-10
Location: Charlotte, NC
Posts: 1,745
iTrader: 0 / 0%
You're not using a host that only reads the .htaccess file once an hour, are you? There's a couple of them out there.
 
Reply With Quote
  #5 (permalink)  
Old 02-07-2010, 07:14 AM
Junior Member
 
Join Date: 02-06-10
Posts: 3
iTrader: 0 / 0%
Quote:
Originally Posted by drmike View Post
You're not using a host that only reads the .htaccess file once an hour, are you? There's a couple of them out there.
I'm on a dedicated server and should work instantly. But I think there's something funny like that going on.
 
Reply With Quote
  #6 (permalink)  
Old 02-07-2010, 07:20 AM
drmike's Avatar
Contributing Member
 
Join Date: 01-22-10
Location: Charlotte, NC
Posts: 1,745
iTrader: 0 / 0%
Some quick google'ing pulls up this thread:

http://www.webhostingtalk.com/archiv.../t-265867.html

Can you please check to see if there's anything in the webserver's error logs and what's listed as your AccessFileName in the config files?
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess not working - i need help mujtabi Coding Forum 4 01-24-2010 10:57 AM
Conflict, What is the right htaccess rule, default homepage file with htaccess? basketmen Coding Forum 2 01-20-2009 07:50 AM
.htaccess 301 not working chowbow Coding Forum 5 07-13-2008 07:05 AM
Two HTML similar codes , one working well and another not working why? Banjika Web Design Lobby 1 06-11-2005 07:14 AM
hotlink protection imei Coding Forum 5 10-15-2004 09:28 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 12:30 PM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.