Server rentals :: NFOservers.com

Forums

All times are UTC - 8 hours



Author Message
PostPosted: Sun May 01, 2011 6:46 pm 
Offline
A semi-regular
A semi-regular
User avatar

Joined: Thu Jul 16, 2009 10:10 pm
Posts: 26
I'd like to use .htaccess to deny entry to particular directories while still allowing access to the files contained in them if directly linked to. In my case, I have a directory that contains a lot of images, but I'd like to prevent people from seeing those images unless I link to them directly. I've tried googling this but the results tend to lead directly to Apache's reference site which is honestly kind of a pain to read.


Top
 Profile  
 
PostPosted: Sun May 01, 2011 7:17 pm 
Offline
Staff
Staff
User avatar

Joined: Fri Sep 17, 2010 9:06 am
Posts: 2018
Location: California
You are indeed in the right location. I came across the answer to your problem because I also host a lot of content on my site and do not like people being able to browse directories. I am looking for the line to add to your .htaccess file as I type..

Hopefully I will find it soon..

_________________
<@TimeX-NFo> Hey, we used to have to carry our packets to the servers.
<@TimeX-NFo> And it was upstream, both ways.

<@TimeX-NFo|away> You're asking the old dude for help?????
<@Kraze^NFo> Yes


Top
 Profile  
 
PostPosted: Sun May 01, 2011 7:18 pm 
Offline
Staff
Staff
User avatar

Joined: Fri Sep 17, 2010 9:06 am
Posts: 2018
Location: California
This should help you..
RewriteCond %{HTTP_REFERER} !yoursite.com [NC]
RewriteRule .* - [F]

Your going to need to customize it of course.

_________________
<@TimeX-NFo> Hey, we used to have to carry our packets to the servers.
<@TimeX-NFo> And it was upstream, both ways.

<@TimeX-NFo|away> You're asking the old dude for help?????
<@Kraze^NFo> Yes


Top
 Profile  
 
PostPosted: Sun May 01, 2011 7:47 pm 
Offline
Founder
Founder
User avatar

Joined: Thu Apr 18, 2002 11:04 pm
Posts: 9222
Location: Seattle
If you use mod_rewrite, you will most likely need this at the top, as well:

RewriteEngine on


Top
 Profile  
 
PostPosted: Sun May 01, 2011 8:24 pm 
Offline
A semi-regular
A semi-regular
User avatar

Joined: Thu Jul 16, 2009 10:10 pm
Posts: 26
Not sure what exactly I'm supposed to customize in those particular lines. The file works--except it also forbids access to the images.


Top
 Profile  
 
PostPosted: Sun May 01, 2011 9:10 pm 
Offline
Founder
Founder
User avatar

Joined: Thu Apr 18, 2002 11:04 pm
Posts: 9222
Location: Seattle
Rereading this, are you just trying to make it so the directory listing doesn't show up? If so, the simplest way is to create a blank index.html file in the folder.

The solution that kraze was giving was meant to defend against external linking.


Top
 Profile  
 
PostPosted: Sun May 01, 2011 9:56 pm 
Offline
A semi-regular
A semi-regular
User avatar

Joined: Thu Jul 16, 2009 10:10 pm
Posts: 26
Ahaha yes that is what I wanted to do, woops, I can't believe I overcomplicated things that badly. WELP, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
It is currently Sun May 19, 2013 12:27 pm
Powered by phpBB® Forum Software © phpBB Group