Isn't this test a little overbroad?  It'll probably be fine in practice, but it would stop us rewriting http://example.com/foo/g?url=ugly or similar.  Would be good for this to work for all urls, however ugly they are.