Fix code to run in MySQL strict mode and support IIS rewrite rules