We have a new wiki. The migration is not 100% complete. You can help out by moving pages across. This wiki will exist for as long as there are pages left.
The official documentation has moved to http://docs.couchdb.org — The transition is not 100% complete, but http://docs.couchdb.org should be seen as having the latest info. In some cases, the wiki still has some more or older info on certain topics inside CouchDB.
See also the official documentation for this topic.
CouchDB, since 0.11.0, can map requests to different locations based on the Host header. This allows different virtual hosts on the same machine to map to different databases or design documents, etc. The most common use case is to map a virtual host to a Rewrite Handler, to provide full control over the application's URIs.
To add a virtual host, add a CNAME pointer to the DNS for your domain name. For development and testing, it is sufficient to add an entry in the hosts file (/etc/hosts on Unix-like operating systems) pointing to 127.0.0.1. For example:
# Aliases for CouchDB vhosts, see /etc/couchdb/local.ini 127.0.0.1 sofa.couchdb
Test that this is working:
$ ping sofa.couchdb PING sofa.couchdb (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64 time=0.025 ms 64 bytes from localhost.localdomain (127.0.0.1): icmp_req=2 ttl=64 time=0.051 ms ^C
Finally, add an entry to your Configuration File in the [vhosts] section:
[vhosts] sofa.couchdb:5984 = /sofa/_design/sofa/_rewrite
If your CouchDB is listening on the default HTTP port, or is sitting behind a proxy, then don't specify a port number in the vhost key.
With the above setup, a request to http://sofa.couchdb:5984/sweet-o will be mapped to http://127.0.0.1:5984/sofa/_design/sofa/_rewrite/sweet-o.