Project directories in Apache

Because I work for various clients on various projects, I wanted to configure my localhost apache server in a way that all my projects can be automatically recognised by apache.

Each of my projects gets a new directory under ~⁄Documents in the form PRJ_project where PRJ is a globally used project code (use it in my mail, time tracking etceteras) and project is the humanreadable name.

Each of these folders contains various subfolders: ~⁄Documents⁄PRJ_project⁄res~⁄Documents⁄PRJ_project⁄admin~⁄Documents⁄PRJ_project⁄wwwetc.

The www folder contains an exact mirror of the site i am working on.
What i wnat is that http:⁄⁄localhost⁄PRJ_project⁄ points to the project PRJ_projects www directory.

Now I could open http.conf or commonhttpd.conf and add some configuraion options for each project, each time i start a new one, but id rather have all of them configured to automatically detect the www directory.

It is really easy by using the AliasMatch and DirectoryMatch tags and some regular expression.

The code that is posted below can be directly inserted in your commonhttp.conf<pre><AliasMatch ^⁄([^⁄])⁄(.)$ ⁄home⁄ber3⁄Documents⁄Projecten⁄$1⁄www⁄$2<DirectoryMatch ⁄home⁄ber3⁄Documents⁄Projecten⁄[^⁄]*⁄www⁄> AllowOverride All Options MultiViews +Indexes Includes FollowSymLinks <IfModule mod_access.c> Order allow,deny Allow from all <⁄IfModule><⁄DirectoryMatch></pre>

Dit artikel verscheen op bler.webschuur.com. En is overgezet naar dit blog

in programming54

Over de auteur: Bèr Kessels is een ervaren webdeveloper met een grote passie voor techniek en Open Source. Een gouden combinatie om de techniek goed en efficiënt toe te passen. Volg @berkes op Mastodon. Of lees meer over Bèr.