model: Add rewrite_url() function. Bug 1905