Anyone's got an idea, i'm still stuck on this one...

gregory duchesnes a écrit :

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} !^www.masterdomain.com$
   RewriteRule ^(.*)   http://www.masterdomain.com$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 :
/var/www/hosts/www.customer-1.com/web
/var/www/hosts/www.customer-2.com/web


a vhost.map file :
www.customer-1.alias-1.com    www.customer-1.com
www.customer-1.alias-2.com    www.customer-1.com
www.customer-2.alias-1.com    www.customer-2.com
www.customer-2.alias-2.com    www.customer-2.com
# ...


and some mod_rewrite :

RewriteEngine on
RewriteMap lowercase int:tolower

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

# 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
Greg
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
  "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
  "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to