fix redirect bugs and sendfile deprecation warning