Update changeflavour.php

Sometimes the referrer has already resolved url encoding to symbols. Fall back to a re-encoded segment if a path segment is not found. If neither is found, fall back to the root node of the target flavour.