0

(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

Fortisimo
  • 101
  • 2

1 Answers1

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]
Artefacto
  • 1,065
  • 1
  • 8
  • 12