Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I need to block directory access but allow access to files if typed into a browser.

Also would like this to load my custom 403.shtml

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted
Options -Indexes
ErrorDocument 403 /path/to/403.shtml

Both lines go into an .htaccess file in your root directory

share|improve this answer
    
Thanks but sorry this does not allow access to files. –  user10560 Oct 27 '11 at 2:51
1  
Do you have any error? Code snippet above must work, if AllowOverride in server's config allow you to use redefines in htaccess –  Lazy Badger Oct 27 '11 at 9:51
    
This does block directory access, however it also blocks file access. Typing either into a browser gives the 403. I'm a bit new to this stuff so I'm not certain on AllowOverride. –  user10560 Oct 27 '11 at 15:16
    
I must admit I'm a bit surprised no one has an answer for this. –  user10560 Oct 28 '11 at 12:24
    
My answer is correct. If it doesn't work for you then your server is not correctly configured or not configured to allow you to do this. –  John Conde Oct 28 '11 at 13:02
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.