Use basepath trailing slash for rewrite rules only in the regex, not for the build string, and not at all if the basepath is empty.