Use templates for rewrite middleware.