Forum Moderators: phranque
Try this?
Options -Indexes
ErrorDocument 403 /
I am not sure how efficient this is, but it works for me.
you will be redirected to frontpage (homepage), but all links on that page will be changed. Let you have page [example324982398.com...] it will be [example324982398.com...]
Why - don`t know!
or you may simply add a blank index.html page to the directory.
I have an HTML web site with many folders. Each folder have many htm pages. I don`t want for some user browse my folders and see list of those pages.
It`s possibel do something to forbid preview all folders and subfolders?
or you may simply add a blank index.html page to the directory.
Also i must add meta redirection in each page - some work...
Not sure why you need any redirection (least of all meta-tag redirects) if your only goal is to prevent directory view of the files?
Do you have some other priorites that you've omitted?
galench, do you have a custom error document that you already use? you could try setting it up to show that page. for example, similar to what craig said:
Options -Indexes
ErrorDocument 403 /your-error-document.html
then, on your-error-document.html, make sure all the images, stylesheets, and javascripts use absolute links instead of relative. like:
bad:
<link rel='stylesheet' type='text/css' href='mystylesheet.css'>
good:
<link rel='stylesheet' type='text/css' href='http://www.mysite.com/mystylesheet.css'>
also good:
<link rel='stylesheet' type='text/css' href='/mystylesheet.css'>
Options -Indexes
ErrorDocument 403 / [R=301,L]
Please note that this is a kludge. You should do a proper page and then redirect from that page if you wish. I have an error.php in my root folder, and I do this:
Options -Indexes
ErrorDocument 404 /error.php?e=404 [L]
ErrorDocument 403 /error.php?e=403 [L]
ErrorDocument 500 /error.php?e=500 [L]
And then, from the error.php page, I give them the ability to search for content, or LINK to the front page. From a design point of view my images and CSS in the error page all link with a "/" in the beginning, e.g., "/images/site.css", so it is relative to the main root folder. This way all the images appear without problems.
Hope this helps.