Environmental control of phosphorylation pathways in a branched two-component system