PDA

View Full Version : Restricting viewing folder contents


GMAN58
9-2-02, 08:54 AM
I want to keep peeps from viewing the contents of folders on my site. In other words, if one goes to www.ky-escaper.com/misc one can view all files in this folder. I would rather have a FORBIDDEN page come up instead. What .ht* file do I need to create, what lines do I need to put in it, and where do I upload the file to.

Thanks in advance !

BTW, I am very very happy with my decision to go POWWEB !! :)

gorstew
9-2-02, 09:10 AM
Originally posted by GMAN58
I want to keep peeps from viewing the contents of folders on my site. In other words, if one goes to www.ky-escaper.com/misc one can view all files in this folder. I would rather have a FORBIDDEN page come up instead. What .ht* file do I need to create, what lines do I need to put in it, and where do I upload the file to.

Thanks in advance !

BTW, I am very very happy with my decision to go POWWEB !! :)

What you need is an .htaccess file (note the DOT before the name htaccess)...

read :- http://help.powweb.com/faqs/htaccess.php

under "Q. How can I make a directory not list certain files?"

Use a PLAIN TEXT editor - not Word or other.. & just include the 3-4 lines of text - one command per line..

& upload to the directory you dont want listed.

G.

GMAN58
9-2-02, 09:16 AM
Thank you for the quick reply, gorstew !!
I searched the forum for around 30 mins. and also read through the Tutorials, but didn't think to browse the FAQ... DOH !!

Cheers !!

EDIT... I did it, it WORKS !! Me so happy !!

curran
9-2-02, 11:17 AM
There is an easier way if you want to block all the content and put up a page stating so. Just create an index.html in that directory and it will always be displayed by default.

Of course, that doesn't stop a person from viewing other files if they know in advance what they are called and what directory they are in. That kind of security would require the .htaccess file.

djeaux
9-3-02, 10:51 AM
Originally posted by curran
There is an easier way if you want to block all the content and put up a page stating so. Just create an index.html in that directory and it will always be displayed by default.

If you don't want to restrict access to the directory other than just to prevent the user from viewing the directory listing, "curran" has the right idea.

I like to throw in a META or JavaScript redirect in the directory index.html file to throw the user to the main entry page or some other point. The example below has both -- change DESTINATION to the URL of the page you want the victim, er, viewer, to go to...


<HTML>
<HEAD>

<TITLE>Oops!</TITLE>

<!-- META type redirection -->
<!-- Substitute target URL in "URL=" below... -->
<!-- This is set for 10 sec delay; substitute as desired... -->
<meta http-equiv="refresh" content="10;URL=http://DESTINATION">

<!-- JavaScript redirect function called from BODY onLoad -->
<SCRIPT Lanugage="JavaScript">
<!-- Enable cloaking device...
function HeadOut() {
// Substitute target URL in next line...
open("http://DESTINATION","self");
}
// -->
</SCRIPT>

</HEAD>

<!-- "10000" sets JavaScript redirect for 10 sec delay in next line... -->
<BODY BGCOLOR="beige" onLoad="timeout=setTimeout('HeadOut()',10000);">

Blah Blah Blah Blah Blah

</BODY>
</HTML>



Joe
www.djeaux.com

djeaux
9-3-02, 10:54 AM
And yes, before I get corrected, there was a typo in the code I posted:

<SCRIPT Lanugage="JavaScript">

should be

<SCRIPT Language-"JavaScript">

Coffee... I need coffee... :-)


Joe
(wiping scrambled egg off face)

dmbgreystreet04
3-19-04, 09:05 PM
I need help in setting up a .htaccess file that will disallow people to view contents in a folder; for example:

http://www.cornerofgrey-street.com/music

I dont want anyone to view whats in that folder or in its subfolders. Rught now I have a simple index.htm file that shows up instead but how would I do it with htaccess??? Thanks to anyone that can help me
:(