Reconfigurable optically-controlled waveguide for terahertz applications