Pull some common logic out into a library class
Add use_url_scheme and use_http_host properties

This allows use of these in the web server rewrite rules so you can support multi-context configurations where contexts represent different domains or sub-domains.
Resolves #5