Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ web/modx1/$1
RewriteRule ^$ test1.html [L]
RewriteCond %{HTTP_HOST} ^www.domain2.com$
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ web/modx2/$1
RewriteRule ^$ test2.html [L]
RewriteCond %{HTTP_HOST} ^www.domain3.com$
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ web/modx3/$1
RewriteRule ^$ test3.html [L]
# Externally redirect non-www hostname requests to canonical www hostnames
RewriteCond %{HTTP_HOST} ^(domain1\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^(domain2\.com) [NC,OR]
RewriteCond %{HTTP_HOST} ^(domain3\.com)
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
#
# Internally rewrite recognized hostname to appropriate subdirectory (unless already done)
RewriteCond $1 !^web/(modx1|modx2|modx3)/
RewriteCond %{HTTP_HOST}>modx1 ^www\.domain1\.com[^>]*>(.+)$ [OR]
RewriteCond %{HTTP_HOST}>modx2 ^www\.domain1\.com[^>]*>(.+)$ [OR]
RewriteCond %{HTTP_HOST}>modx3 ^www\.domain1\.com[^>]*>(.+)$
RewriteRule ^(.*)$ /web/%1/$1 [L]