httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gregory duchesnes <>
Subject [users@httpd] mod_rewrite mass virtual hosting and aliases
Date Mon, 05 Dec 2005 16:30:08 GMT
Hi all,

i'm trying to set up some kind of ISP style virtual hosting, the problem 
is some domains have a lot of aliases (which i need to redirect to the 
master domain with à code 301).

I thought of using mod_vhost_alias this way:
- create a folder for the master domain
- create a symlink to the master domain for each alias
- add a .htaccess in the master domain root in which i do the 
redirection in case SERVER_NAME != master domain :
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*)$1  [QSA,L,R=301]

this design works but is not elegant since i would have tons of symlinks 
in my /var/www folder.

I then tried with mod_rewrite but since i'm not a guru, it's getting 
harder (really harder), here is what i tried :

some real folder corresponding to the master domains :

a file :
| ||
|| ||
|| ||
|| |||
|# ...

and some mod_rewrite :

||RewriteEngine on
RewriteMap lowercase int:tolower

# define the map file
RewriteMap vhost txt:/www/conf/

# deal with aliases as above
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
# if folder exists as a master domain
||RewriteCond /var/www/hosts/${lowercase:%{SERVER_NAME}}/web ^(.+)$
# do the magic
||||RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/web/$1 [S=1]|
|# else redirect to the master domain
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^(.*)   http://%1/$1  [QSA,L,R=301]

Of course it doesn't work, but first of all is it completely stupid? And 
if not, how to make it work (if it's clear enough)?

Thanks for your help

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message