Rewrite rule and app env