Rewrite static middleware