Properly deal with trailing slashes in URLs