Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page How to redirect directory listing requests?
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
ervion is on a distinguished road
 
Posts: 5
Join Date: May 2012
Question How to redirect directory listing requests? - 07-31-2012, 04:49 PM

I don't want to let visitors list my directories. When visitors try to list directory, they should land on custom site, that says, that "directory listing is not allowed and blah-blah", or if this is absolutely impossible, then I want them to land on my custom 404.

With "Options –Indexes" in .htaccess, when someone tries to list directory, they see http://error404.000webhost.com/, instead of my custom error page(when mistyping address, custom 404 works). And I totally do not want visitors to see that page.

With "IndexIgnore *" visitors see simply "Index of ...", and I dont want them to see that either.

I found somewhere that:
"Options +Indexes
IndexOptions +SuppressHTMLPreamble
IndexIgnore *
HeaderName /includes/header.html
ReadmeName /includes/readme.html"
where my custom content would be in header.html
BUT for some reason header wasnt working, and i stil got simply "Index of ..."
Are headers disabled? Or what am I doing wrong?

So, could anyone point me directions how to make it work?
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
ShocK's Avatar
Senior Member
ShocK is on a distinguished road
 
Posts: 4,231
Join Date: Jul 2011
Location: UK
Default 07-31-2012, 07:22 PM

You could put an index.html file in each directory you don't want to be viewed with whatever you want in that file. Or just a blank index.html file.
Reply With Quote
(#3 (permalink))
Old
Doug Lochert's Avatar
Senior Member
Doug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond reputeDoug Lochert has a reputation beyond repute
 
Posts: 416
Join Date: Jun 2012
Default 07-31-2012, 08:23 PM

Alternatively, you could place an .htaccess in each directory you wish to be protected with the following lines:

allow from localhost
deny from All

And then edit the .htaccess within your parent directory (public_html) to include the following line:

ErrorDocument 403 /error.php

*Where error.php is your custom error file
Reply With Quote
(#4 (permalink))
Old
rs3511's Avatar
Junior Member
rs3511 is on a distinguished road
 
Posts: 21
Join Date: Jul 2012
Default 07-31-2012, 09:19 PM

Better yet, get a CMS like Joomla or Wordpress. Most directory level security is already built into the core software.
Reply With Quote
Reply

Tags
.htaccess, 404, directory

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com