In case the script live in the root directory, `dirname` will return `/` and hence this will result in `//`, while the expected output would be just `/`. Furthermore, to adhere to HTTP standards, redirects must feature the full path; in your patch the domain name and protocol are not included, but should.