title: CouchDB vhost rewrite to access root API
body: <p>I wish the following rewrite rule worked:</p>
  
  <pre><code>{
    "from": "api/*",
    "to": "../../../*"
  }
  </code></pre>
  
  <p>… in a <em>vhost</em> rewrite like the following:</p>
  
  <pre><code>[vhosts]
  myapp = /myapp/_design/myapp/_rewrite
  </code></pre>
  
  <p>Then it would be possible to access the root API in a following manner:</p>
  
  <pre class="lang-js prettyprint-override"><code>$.couch.urlPrefix = '/api';
  
  var dbs = $.couch.allDbs({
    success: function (data) {
      console.log(data);
    }
  })
  </code></pre>
  
  <p>But unfortunately the request to <code>http://myapp:5984/api/_all_dbs</code> results into:</p>
  
  <pre><code>{"error":"insecure_rewrite_rule","reason":"too many ../.. segments"}
  </code></pre>
  
  <p>Am I missing something? Is something wrong with the rewrite? Does anyone know how to overcome that?
  My Couchdb is 1.1.1.</p>
  
  <p>I'm acquainted to <a href="https://stackoverflow.com/a/6641099/133257">this advice</a>, but don't like any of the suggested ways.</p>