refactor nginx rewrite rules