Rewriting resource retrieval