title: How to configure exist-db app in apache virtual host?
body: <p>On apache server I'm trying to do the following:<br><br>
  myapp1.mydomain.com should open an exist-db app<br>
  myapp2.mydomain.com should open another exist-db app and so on.<br><br>
  I've read the documentation and tried all the solutions given here, but unfortunately I still can't get it work.<br>
  I have this in apache conf:</p>
  
  <pre><code>&lt;VirtualHost xx.xx.xx.xxx:80&gt;
  ServerName myapp1.mydomain.com
  
  ProxyRequests off
  ProxyPreserveHost on
  
  ProxyPass / http://localhost:8080/exist/apps/myapp1/
  ProxyPassReverse / http://localhost:8080/exist/apps/myapp1/
  
  ProxyPassReverseCookiePath /exist /
  ProxyPassReverseCookieDomain localhost myapp1.mydomain.com
  
  RewriteEngine       on
  RewriteRule         ^/(.*)$     /$1   [PT]
  &lt;VirtualHost&gt;
  </code></pre>
  
  <p>The problem is that when I write "myapp1.mydomain.com" in the bowser, it gives this:</p>
  
  <pre><code>Problem accessing /exist/apps/myapp1/exist/apps/myapp1/index.html. Reason:
  
  Document /db/apps/myapp1/exist/apps/myapp1/index.html not found
  </code></pre>
  
  <p>Obviously, I'm doing something wrong, so any help would be appreciated!</p>
  
  <p>P.S. answering the question by @adamretter - yes, there's a controller.xql:</p>
  
  <pre><code>xquery version "3.0";
  
  import module namespace login-helper="http://exist-db.org/apps/dashboard/login-helper" at "modules/login-helper.xql";
  import module namespace login="http://exist-db.org/xquery/login" at "resource:org/exist/xquery/modules/persistentlogin/login.xql";
  
  declare variable $exist:path external;
  declare variable $exist:resource external;
  declare variable $exist:controller external;
  declare variable $exist:prefix external;
  declare variable $exist:root external;
  
  if ($exist:path eq "/") then
      (: forward root path to index.xql :)
      &lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
          &lt;redirect url="index.html"/&gt;
      &lt;/dispatch&gt;
  else if (ends-with($exist:resource, ".html")) then
      (: the html page is run through view.xql to expand templates :)
      &lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
          &lt;view&gt;
              &lt;forward url="{$exist:controller}/modules/view.xql"/&gt;
          &lt;/view&gt;
          &lt;error-handler&gt;
              &lt;forward url="{$exist:controller}/error-page.html" method="get"/&gt;
              &lt;forward url="{$exist:controller}/modules/view.xql"/&gt;
          &lt;/error-handler&gt;
      &lt;/dispatch&gt;
  (: Resource paths starting with $shared are loaded from the shared-resources app :)
  else if (contains($exist:path, "/$shared/")) then
      &lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
          &lt;forward url="/shared-resources/{substring-after($exist:path, '/$shared/')}"&gt;
              &lt;set-header name="Cache-Control" value="max-age=3600, must-revalidate"/&gt;
          &lt;/forward&gt;
      &lt;/dispatch&gt;
  
  (: images, css are contained in the top /resources/ collection. :)
  (: Relative path requests from sub-collections are redirected there :)
  else if (contains($exist:path, "/resources/")) then
      &lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
          &lt;forward url="{$exist:controller}/resources/{substring-after($exist:path, '/resources/')}"&gt;
              &lt;set-header name="Cache-Control" value="max-age=3600, must-revalidate"/&gt;
          &lt;/forward&gt;
      &lt;/dispatch&gt;
  
  else
      (: everything else is passed through :)
      &lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
          &lt;cache-control cache="yes"/&gt;
      &lt;/dispatch&gt;
  </code></pre>