Add 'rewrite' middleware