Connecting Tech Pros Worldwide Forums | Help | Site Map

How do i protect files in directory from being listed and viewed

luckysanj's Avatar
Member
 
Join Date: May 2009
Location: Nepal
Posts: 62
#1: Jul 31 '09
I am developing the free e-book sites.so i I want to know how to prevent the subfolders from websites.

Means, when we open the home page like www.best4knowledge.com then it first open index page then it's ok but users may be guess that there will be any folder & open like that www.best4knowledge.com/front/ . & it shows all the files but it is not secure for me to show all files.

So plz guide me how can i prevent to that files from un authentic person.

Thank you.

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


What server are you using? IIS, Apache?
luckysanj's Avatar
Member
 
Join Date: May 2009
Location: Nepal
Posts: 62
#3: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


Apache Server Because i am programming on PHP language.
KUB365's Avatar
Administrator
 
Join Date: Jul 2005
Location: Portland, OR
Posts: 975
#4: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


one way to do this without setting up secure password is to using an apache .htaccess file

Add the following in a file called .htaccess and upload it to the folder called "front"

Expand|Select|Wrap|Line Numbers
  1. <Directory ~ "\.front">
  2. Order allow,deny
  3. Deny from all
  4. </Directory>
  5.  
The other way to do this is setup a username and then password protect the folder. You'll find an easy to follow howto with complete directions and tools at this url:
http://www.ilisys.com.au/support/lin...sword-protect/
luckysanj's Avatar
Member
 
Join Date: May 2009
Location: Nepal
Posts: 62
#5: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


Ok with this method the folder are hidden from browser. But

he link files from subfolder doesn't work. when the index page call the pages from subfolder it can't access.

Then How can i solve ?
KUB365's Avatar
Administrator
 
Join Date: Jul 2005
Location: Portland, OR
Posts: 975
#6: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


If you want to stop allowing your users to view the directory's files you can do one of two things:

1) create a blank index.html file and upload it to /front/

or

2) you might try create an .htaccess file with the following code and upload it to your /front folder

Expand|Select|Wrap|Line Numbers
  1. <Directory ~ "\.front"> 
  2. Options -Indexes 
  3. </Directory>
  4.  
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#7: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


Quote:

Originally Posted by luckysanj View Post

Apache Server Because i am programming on PHP language.

You can program 'on PHP' using IIS, you know. :)

Going to move this over to Apache.
luckysanj's Avatar
Member
 
Join Date: May 2009
Location: Nepal
Posts: 62
#8: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


It doesn't work. It is like same problem. it display all the subfolder pages.
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,572
#9: Jul 31 '09

re: How do i protect files in directory from being listed and viewed


Quote:

Originally Posted by luckysanj View Post

It doesn't work. It is like same problem. it display all the subfolder pages.

First, which option did you try? Remember, if you add to your httpd.conf file, you have to restart your apache server for the changes to take effect.

Regards,

Jeff
Newbie
 
Join Date: Dec 2007
Posts: 3
#10: Aug 1 '09

re: How do i protect files in directory from being listed and viewed


You can keep an index file(index.html or which ever file you gave in DirectoryIndex) in your "front" directory or which ever directory you want to hide listing of files. It will prevent listing of files and directories.
Reply