Handles relative URL rewriting, see http://goo.gl/Y5ERIY