I've got this setup that works almost all right and, apparently, works the exact same way than this:
UseCanonicalNames off
<VirtualHost *:8888>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example1\.com
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.com(.*) /var/www/html/$1$2 [L]
</VirtualHost>
What it does is redirecting everything www.NNN.com
except example1
to their respective folder, inside /var/www/html/NNN
. That's the basics of what I need. It has the added bonus of allowins a name (example1
) to host all other names within itself at example1/NNN/
, which is also working fine!
The main issue, maybe, is it's all configured behind an Amazon ELB directing port 80 to internal 8888.
So, the only problem I've detected so far is: if I point the browser to www.example.com/anything/
it's just fine, but to www.example.com/anything
(without the last slash) it will redirect the browser to a broken link www.example.com:8888/anything/
be it with example
or NNN
.
Now, I do realize I probably shouldn't be using Rewrite for this, and I'm already trying to change everything to mod_vhost_alias instead but it kept me wondering if there's anything that could be done to fix the problem above along with any further issue that might raise for I was not using the "proper way" with UseCanonicalNames on
and ServerName
for obvious reasons (I don't think we can set multiple ServerName
s without multiple VirtualHost
s). Of course, using them would be ideal, but I couldn't find any way and thus why I'm going the other direction now.
So, anyone steps forward? :)