Fix bug with directory redirects truncating the url