Updated rewrite rules code