2 Replies - 1781 Views - Last Post: 27 November 2010 - 06:14 AM

#1 Guest_Cynthia_Brady*


Reputation:

How to block users from accessing a directory.

Posted 26 November 2010 - 04:31 PM

Hey guys. I want to block my site visitors from browsing to the /gallery directory as it contains photos that they may copy without permission. I can block it completely because part of the site uses the images. But i want to prevent the user from just going to www.mySite.com/gallery/img.jpg to see the full thing. I know this is not a complete prevention from people stealing images, but it would be a nice roadblock.

Thanks!
Is This A Good Question/Topic? 0

Replies To: How to block users from accessing a directory.

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: How to block users from accessing a directory.

Posted 26 November 2010 - 05:37 PM

Hey.

Quote

I want to block my site visitors from browsing to the /gallery directory as it contains photos that they may copy without permission. I can block it completely because part of the site uses the images.

I can't make much sense of this. Are you trying to block all the images, or do you need some of them to be publicly available?

If you need the images to be available in any form, they need to be accessible. If you block the user from going to /gallery/img.jpg, that URL will also become unavailable for all other purposes. There is no difference between the user typing in the URL and the browser automatically fetching it for an <img> box.

But anyways, to answer the question. We'd need to know which type of HTTP server you are running to advice you on how to block things. It's usually pretty straight forward though. For example, in Apache you can usually just create a .htaccess file in the directory you want to block and put Deny from all into it.
Was This Post Helpful? 0
  • +
  • -

#3 husseycoding  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 52
  • View blog
  • Posts: 174
  • Joined: 23-June 10

Re: How to block users from accessing a directory.

Posted 27 November 2010 - 06:14 AM

Hi Cynthia_Brady,

Atli's suggestion is an option if you don't want anything to be able to access the directory, but this includes the server so you can no longer serve any content from that directory. I would suggest again creating an .htaccess file at your server root but instead putting the following line into it:

Options -Indexes


This will stop the indexing of files when a user browses to a directory as you describe and they will just see a 'Forbidden' error message page.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1