title: Apache proxying subdomain root requests
body: <h2>Description</h2>
  
  <ul>
  <li><p>Internal Tomcat server that has webapps listening on 8080:<br/><br/>
  <strong>"http://internal:8080/foo-webservice/"</strong><br/>
  <strong>"http://internal:8080/foo-website/"</strong><br/></p></li>
  <li><p>External facing Apache server is proxying requests for a subdomain:<br/><br/>
  <strong>"http://foo.domain.com/"</strong></p></li>
  <li><p>Any requests of the root of the subdomain would be proxied to the foo-website webapp on Tomcat.</p></li>
  <li><p>Any other requests would be proxied to the appropriate path / webapp</p></li>
  </ul>
  
  <h2>Use Case A</h2>
  
  <ul>
  <li><p>Request:<br/>
  <strong>"http://foo.domain.com/index.html"</strong><br/></p></li>
  <li><p>Proxied to:<br/>
  <strong>"http://internal:8080/foo-website/index.html"</strong><br/></p></li>
  </ul>
  
  <h2>Use Case B</h2>
  
  <ul>
  <li><p>Request:<br/>
  <strong>"http://foo.domain.com/webservice/listener.html?param1=foo&amp;param2=bar"</strong><br/></p></li>
  <li><p>Proxied to:<br/>
  <strong>"http://internal:8080/foo-webservice/listener.html?param1=foo&amp;param2=bar"</strong><br/></p></li>
  </ul>
  
  <h2>VirtualHost definition</h2>
  
  <ul>
  <li><p>Current virtual host definition which satisfies Use Case B:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName foo.domain.com
  
      ProxyRequests Off
  
      &lt;Proxy *&gt;
          Order deny,allow
          Allow from all
      &lt;/Proxy&gt;
  
      ErrorLog /var/log/apache2/foo_error.log
      LogLevel warn
      CustomLog /var/log/apache2/foo_access.log combined
  
      # RewriteRules
      # ?
  
      # ProxyPass
      ProxyPreserveHost On
      ProxyPass        / http://internal:8080/
      ProxyPassReverse / http://internal:8080/
  &lt;/VirtualHost&gt;
  </code></pre></li>
  </ul>
  
  <h2>Attempt 1</h2>
  
  <pre><code>    # RewriteRules
      RewriteEngine On
      RewriteRule ^/(.*) http://internal:8080/foo-website/$1 [P]
  </code></pre>
  
  <ul>
  <li>Use Case A is satisfied</li>
  <li>Use Case B fails</li>
  </ul>
  
  <h2>Attempt 2</h2>
  
  <pre><code>    # RewriteRules
      RewriteEngine On
      RewriteRule ^/$ http://internal:8080/foo-website/$1 [P]
  </code></pre>
  
  <ul>
  <li>Use Case B is satisfied</li>
  <li>Use Case A is not completely satisfied</li>
  <li>The index.html in foo-website is loaded, but none of the files in the js, img or css folders.</li>
  </ul>