1

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

  1. we.com
  2. we.fr
  3. doo.com
  4. doo.fr
  5. fpp.com
  6. ke.com
  7. wpp.com
  8. wgg.com
  9. t-y-u.fr

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. http://stats.we.com/ change the base directory to /web/we_com
 2. http://stats.we.fr/ change the base directory to /web/we_fr
 3. http://stats.doo.com/ change the base directory to /web/doo_com
 4. http://stats.doo.fr/ change the base directory to /web/doo_fr
 5. http://stats.fpp.com/ change the base directory to /web/fpp_com
 6. http://stats.ke.com/ change the base directory to /web/ke_com
 7. http://stats.wpp.com/ change the base directory to /web/wpp_com
 8. http://stats.wgg.com/ change the base directory to /web/wgg_com
 9. http://stats.t-y-u.fr/ 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 we.com
    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 "_") !

3 Answers 3

1

Can't you use - instead of _ for t-y-u.fr ? 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 stats.we.com stats.we.fr stats.doo.com ...
</VirtualHost>

Check http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html 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 :

/web/domaine.tld/public/
/web/domaine.tld/public/www/
/web/domaine.tld/public/stats/
/web/domaine.tld/public/..
/web/domaine.tld/logs/

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

1
  • Thak you that's exactly what i was looking for, I'll check it out Jun 20, 2009 at 7:35
2

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.

1

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.

You must log in to answer this question.

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