added URI rewriting (fixes #98); also added `Unauthorized` exception for 401 responses