Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Web Design & Development
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry repair router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: .htaccess Question

Reply  
Thread Tools
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
24-May-2007, 06:51 PM #1
Question Solved: .htaccess Question
Hello. I would like to configure my .htaccess file to protect .jpg and .gif images from being hot-linked. For some reason, it is not working. This is what I have so far:
Code:
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?correctnesscommentary.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]
.ohtaccess:
Code:
IndexIgnore *
Also, does anyone know how I can alter this file to prevent access to a specific folder (e.g. correctnesscommentary.com/examplefolder)?

Thanks!
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
25-May-2007, 10:29 PM #2
Did you misspell the filename. It should be .htaccess. Otherwise it looks correct.

If you want to prevent access to a folder put an .htaccess file in there and password protect it.
http://www.javascriptkit.com/howto/htaccess3.shtml
tomdkat's Avatar
Computer Specs
Distinguished Member with 7,127 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
26-May-2007, 12:30 PM #3
Quote:
Originally Posted by pcpro17
Hello. I would like to configure my .htaccess file to protect .jpg and .gif images from being hot-linked. For some reason, it is not working.
I had a similar issue on a server I admin. I use Apache 2.0.59 as the web server and I found I had to specify an "AllowOverride [something]" directive in the virtual host definition of the site I wanted to prevent hot-linking on in order for the .htaccess file to be processed.

So, I would put other directives in your .htaccess file to make sure .htaccess is even being read and processed. There is also a RewriteEngineLog directive you can possibly utilize to get error messages regarding your Rewrite rules. You might need to ask your website hosting service tech support for help with this.

Good luck!

Peace...
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
29-May-2007, 01:20 PM #4
Thanks for the help folks!
tomdkat's Avatar
Computer Specs
Distinguished Member with 7,127 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
29-May-2007, 01:24 PM #5
What did you end up doing?

Peace...
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
12-Jun-2007, 12:56 PM #6
Hi Tom. I eventually got it working, but it took a while:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} ^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
It turned out that the problem in the code I orignally posted was the exclaimation mars ("!") needed to be removed. Thanks.
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
12-Jun-2007, 01:11 PM #7
Okay, so after some additional testing, it does not seem to be working properly. Anyone can hotlink images still.

http://www.correctnesscommentary.com/images/banner.jpg

What is the exclaimation mark ("!") and dollar sign ("$") supposed to do in a .htaccess file?
tomdkat's Avatar
Computer Specs
Distinguished Member with 7,127 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
12-Jun-2007, 06:12 PM #8
Here is a .htaccess file I use on a site I host and it works fine:
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?website.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.website.com/no-hotlink.jpg [R,L]
The only way I could get it to work was to make sure the "AllowOverride" directive was setup to enable actual processing of the .htaccess file. The exclamation points are fine.

Peace...
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
12-Jun-2007, 06:20 PM #9
AllowOverride? What's that? :-\
tomdkat's Avatar
Computer Specs
Distinguished Member with 7,127 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
12-Jun-2007, 06:28 PM #10
Read post #3 above.

Peace...
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
13-Jun-2007, 01:07 PM #11
Okay, I finally sent in a request to my hosting support, and the issue now seems to be resolved:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?correctnesscommentary\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
tomdkat's Avatar
Computer Specs
Distinguished Member with 7,127 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
13-Jun-2007, 01:13 PM #12
Quote:
Originally Posted by pcpro17
Okay, I finally sent in a request to my hosting support, and the issue now seems to be resolved:
Great! What did they do? Did they define an "AllowOverride" directive for your site?

Peace...
pcpro17's Avatar
Computer Specs
Member with 441 posts.
 
Join Date: Oct 2006
Location: Wisconsin, USA
Experience: Intermediate
16-Jun-2007, 08:09 PM #13
I'm not sure. I just sent them my .htaccess code, and they told me how to fix it.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:34 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.