Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's my goal : I have 9 websites running (names changed of course) :


I wanted for each website :

  1. a directory to put a rotating log file. Done.
  2. update awstats for each on a 24 h basis and put the results in a separate directory :
  - /web/awstats/we_com/
  - /web/awstats/we_fr/
  - /web/awstats/doo_com/
  - /web/awstats/doo_fr/
  - /web/awstats/fpp_com/
  - /web/awstats/ke_com/
  - /web/awstats/wpp_com/
  - /web/awstats/wgg_com/
  - /web/awstats/t_y_u_fr/
  1. make only one virtual host for a generic stats website and given a name, re-direct to the good statistics website. If you type one of those URLs the base path for the site should be changed accordingly :
 1. change the base directory to /web/we_com
 2. change the base directory to /web/we_fr
 3. change the base directory to /web/doo_com
 4. change the base directory to /web/doo_fr
 5. change the base directory to /web/fpp_com
 6. change the base directory to /web/ke_com
 7. change the base directory to /web/wpp_com
 8. change the base directory to /web/wgg_com
 9. change the base directory to /web/t_y_u_fr

I've done it but it's sooooooo long : for each site here are the rules :

    # site
    RewriteCond %{HTTP_HOST}  ^stats\.we\.com
    RewriteRule ^/$ /we/awstats.we.xml [QSA,L]
    # change other dirs to the base dir :
    RewriteCond %{HTTP_HOST}  ^stats\.we\.com
    RewriteCond %{HTTP_HOST}  ^stats\.we\.com
    RewriteRule ^/(.*) /wheeg/$1 [QSA,L]

if you have a good way of optimizing it i'd like to see it (remember there's one site with "-" and they have to be changed to "_") !

share|improve this question
up vote 1 down vote accepted

Can't you use - instead of _ for ? because you could use a unique mass vhost configuration like this one for all your domains :

<VirtualHost *>
    VirtualDocumentRoot /web/awstats/%-2_%-1/
    ServerName anything
    ServerAlias ...

Check for more documentation. May be by adding a rewrite rule you could change - by _ in the DocumentRoot path. This need some tries.

But generaly, tree are done like this :


And with one vhost by domaine using VirtualDocumentRoot you can do what you want.

share|improve this answer
Thak you that's exactly what i was looking for, I'll check it out – Olivier Pons Jun 20 '09 at 7:35

First rule of optimization: don't. Second rule of optimization (advanced use only): don't yet.

If it is working already, and is not causing any performance or maintenance issues, I would leave well alone.

share|improve this answer

Also bear in mind, putting mod_rewrite rules in central apache config files is more efficient that using .htaccess files, as they .htaccess file have to be re-read every time the site is requested.

share|improve this answer

Your Answer


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.