RewriteRule multi subdomains doesn't work

#1
Hello,
I've setup up 3 external apps for 3 subdomains and i've used the following rewrite rule: (on example.com)

RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://subdomain1_ext_proxy/$1 [P,E=Proxy-Host:subdomain1.mydomain.com]
RewriteRule ^(.*)$ http://subdomain2_ext_proxy/$1 [P,E=Proxy-Host:subdomain2.mydomain.com]
RewriteRule ^(.*)$ http://subdomain3_ext_proxy/$1 [P,E=Proxy-Host:subdomain3.mydomain.com]

The problem is the the 3 subdomains redirect the the subdomain1_ext_proxy.

Any ideas ?

Thank you
 

Cold-Egg

Administrator
#2
You can either create a rewritecond to match each subdomain, or create additional virtual hosts for each subdomains, so it won't all hit the first rewriterule only.
 
#3
Awesome it worked! Thank you very much

Here's the script if anybody else needs it:
RewriteCond %{HTTP_HOST} ^subdomain1.mydomain.com
RewriteRule ^(.*)$ http://subdomain1_ext_proxy/$1 [P,E=Proxy-Host:subdomain1.mydomain.com]
RewriteCond %{HTTP_HOST} ^subdomain2.mydomain.com
RewriteRule ^(.*)$ http://subdomain2_ext_proxy/$1 [P,E=Proxy-Host:subdomain2.mydomain.com]
RewriteCond %{HTTP_HOST} ^subdomain3.mydomain.com
RewriteRule ^(.*)$ http://subdomain3_ext_proxy/$1 [P,E=Proxy-Host:subdomain3.mydomain.com]
 
Top