Added rewriteURL method