Rewrite rules architecture