+ Reply to Thread
Results 1 to 6 of 6

Thread: How can I block the access of directory files?

  1. #1
    ciril tomy's Avatar
    ciril tomy is offline x10Hosting Member ciril tomy is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    TOKYO, JAPAN
    Posts
    53

    Question How can I block the access of directory files?

    Hi Friends!
    I have a problem with my site that when I type my file name such as www.mysite.com/images/
    All the images could be seen by everyone. Can anybody tell me to solve this issue.
    I heard from someone that i can do it by .htaccess but I don`t know what to write...

    I have to block all directory files access from public.
    Please help me to solve this...

    Thanks in advance.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How can I block the access of directory files?

    There are many threads that cover this, such as "10hosting shows all contents of a folder!"
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    oraya68 is offline x10Hosting Member oraya68 is an unknown quantity at this point
    Join Date
    Dec 2009
    Location
    Beautiful Cornwall in England
    Posts
    27

    Re: How can I block the access of directory files?

    Quote Originally Posted by ciril tomy View Post
    Hi Friends!
    I have a problem with my site that when I type my file name such as www.mysite.com/images/
    All the images could be seen by everyone. Can anybody tell me to solve this issue.
    I heard from someone that i can do it by .htaccess but I don`t know what to write...

    I have to block all directory files access from public.
    Please help me to solve this...

    Thanks in advance.

    Cyril you can add the rule Deny from all to your .htaccess file.

    Kind regards
    Oraya

    PS here's a link that will explain it for you.

    http://www.kavoir.com/2009/01/htacce...ry-access.html

    Another PS
    You may also want to disallow spiders/robots, from indexing your image folder also so you may want to create a robot txt.
    To stop them indexing a single folder you would do it like this:
    User-agent: *
    Disallow: /foldername/

    foldername being the image folder etc.
    Last edited by oraya68; 12-17-2009 at 08:21 PM. Reason: added a link to post.

  4. #4
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: How can I block the access of directory files?

    [sarcasm]Ooh yes, deny from all, that won't do anything bad![/sarcasm]
    I suppose you're talking about directory listing? When you go to a directory that doesn't contain an index file, you get a list of all files in the directory?

    The solution is easy, put a .htaccess file in the directory (or any parent directory of that directory) containing the following (or append it to the existing .htaccess document).

    Code:
    Options -indexes
    Note: deny from all will block ALL access to all files in that directory. Including the access required to view images when you're allowed to.

  5. #5
    oraya68 is offline x10Hosting Member oraya68 is an unknown quantity at this point
    Join Date
    Dec 2009
    Location
    Beautiful Cornwall in England
    Posts
    27

    Re: How can I block the access of directory files?

    Quote Originally Posted by marshian View Post
    [sarcasm]Ooh yes, deny from all, that won't do anything bad![/sarcasm]
    I suppose you're talking about directory listing? When you go to a directory that doesn't contain an index file, you get a list of all files in the directory?

    The solution is easy, put a .htaccess file in the directory (or any parent directory of that directory) containing the following (or append it to the existing .htaccess document).

    Code:
    Options -indexes
    Note: deny from all will block ALL access to all files in that directory. Including the access required to view images when you're allowed to.
    Yes well op did say he wanted to block all access from the public, so that would do it!! And like you pointed out he could add options. You'll note I also included a link for him to read up further.

    Oh and by the way if he wanted to allow site to load images on a page, that can be done by adding the site ip...
    Works fine for me!

    Oraya
    Last edited by oraya68; 12-20-2009 at 01:46 AM.

  6. #6
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: How can I block the access of directory files?

    Quote Originally Posted by oraya68 View Post
    Yes well op did say he wanted to block all access from the public, so that would do it!! And like you pointed out he could add options. You'll note I also included a link for him to read up further.

    Oh and by the way if he wanted to allow site to load images on a page, that can be done by adding the site ip...
    Works fine for me!

    Oraya
    If you allow the IP of the site, then the site's server can access the images through http, but no user will be able to do so. You'd have to manually add all users to allow access to your images.
    Furthermore, if you don't disable directory listing, anyone who is allowed to see any images is also able to view the directory index. As a result, the OP will have a lot of work and no solution.

    Either I wouldn't want to visit your site or you've certainly included a link to the wrong information :nuts:
    Have you even read and understood it yourself?

+ Reply to Thread

Similar Threads

  1. trouble with "ftp configuration" and filezilla
    By selcane in forum Free Hosting
    Replies: 6
    Last Post: 12-12-2008, 09:08 AM
  2. 'Access denied' when uploading via FTP
    By jamiek in forum Free Hosting
    Replies: 0
    Last Post: 11-25-2008, 07:14 AM
  3. Loading of files in what directory?
    By letrletr in forum Free Hosting
    Replies: 5
    Last Post: 09-25-2008, 06:09 PM
  4. Cant access my files
    By alexxz4 in forum Free Hosting
    Replies: 9
    Last Post: 04-02-2008, 03:07 PM
  5. how to access my public ftp files
    By ronsix in forum Free Hosting
    Replies: 1
    Last Post: 09-12-2007, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers