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).