0

This syntax seems to prevent Apache from serving any pages from /var/www or subdirectories.

 <Directory "/var/www">
     Allow from None
     Order allow,deny
 </Directory>

I wantthis behavior as a general rule, with some exceptions. For example I want users to be able to access

 /var/www  
 /var/www/css
 /var/www/js

but not:

 /var/www/app
 /var/www/xml
 /var/www/foo
 /var/www/bar
 ... and many more
1
  • What is it you're wondering? You already know that the Directory directive gives you a way to control your directories, what is it that's not working the way you want?
    – Jenny D
    Jan 9, 2013 at 15:30

2 Answers 2

0

If you allow from none or deny from all then no one is allowed access to the directory content.

if you want finer control than all or nothing you should look at the access controls in the apache docs which is basically

[ allow | deny ] from address

address can be a domain an ip or a hostname.

0

You could work with DirectoryMatch to set a deny rule on most directories except some of them.

But I think your real problem is that you have a lot of folders inside your web directory root (/var/www) and you do not want anyone to access theses directories. So why are they here?

A cleaner path organisation would be:

  • /path/to/project : the project root
  • /path/to/project/www : the project apache document root (DocumentRoot))
  • /path/to/project/www/[js|css] : some valid web assets
  • /path/to/project/lib : libraries of the apllication, the code
  • /path/to/project/lib/[app|xml|foo|bar] : libraries of the aplication, the code
  • /path/to/project/[etc|doc|var|tmp] : other things

Apache cannot access anything before the DocumentRoot except if you set some aliases, but you do not need aliases. all the things that do not require derect access via an url should not be under the DocumentRoot. Most CMS ignores this basic rule simply because they want to be easily deployed on very restrictive hosts policies (where you only have access tco the document root via ftp).

This could be done with any language, jsp' asp' php. You only need a bootstraper file (namely index.php, index.jsp, index.asp) in the web directory root, any other resource is loaded into the application via include directives and library path settings.

You will avoid a lot of information disclosure problems with that (except for all the stuff you could find attached to js libraries packages, be sure to suspend php execution on js assets paths).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .