Return 404 when not route is found and properly encode query string when redirecting