When selecting an instance to use, match the configured prefixes against full URL, not just $_SERVER['HTTP_HOST'].
In fact, the URL is still not full, but we'll match against $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], which is much more flexible.
Also, this commit fixes Google Code Issue 29 (DB Connection Error) by exiting with an error if none of the configured instances have been selected