Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

(1)I'm currently in the process of moving a project to a web host.

(2)I want to install the site into a sub-domain - ie. sub.domain.com

(3)I've directed sub.domain.com to a sub-directory of the server root: /sub/public_html

(4)/sub has 2 directories:

`public_html` - for the publicly traversable files & directories
`resources` - for sensitive documents

(3)I now want:

  (a)users to be able to visit `sub.domain.com` and traverse the contents of `public_html`

  (b)users NOT to be able to traverse the contents of 'resources`

  (b)users NOT to be able to view the DIRECT/IMMEDIATE contents of the server root

My questions are:

(1) Can this be done with .htaccess?

(2) If so, how?

Thanks.

EDIT: meant /sub/public_html instead of just /sub

share|improve this question
add comment

1 Answer 1

The obvious answer is to change the server root of the subdomain to sub/public_html instead of public_html. If you don't want user to be able to access anything below that, don't include it the server root. Server-side scripts will still be able to access the directory.

That said, you can do that, with a performance penalty, in a .htaccess:

RewriteEngine On
RewriteRule ^public_html/ - [L]
RewriteRule ^resources - [R=403,L]
RewriteRule .* public_html/$0 [L,QSA]
share|improve this answer
    
Thanks for your input. However, what about stopping the issue of a user being able to view every thing by just traversing as domain.com/../..? –  Fortisimo Aug 22 '10 at 23:24
1  
@Tunji Apache won't allow that... –  Artefacto Aug 22 '10 at 23:45
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.