In this paper, a strict Lyapunov function is developed in order to show the exponential stability and input-to-state stability (ISS) properties of a diffusion equation for nonhomogeneous media. Such media can involve rapidly time-varying distributed diffusivity coefficients. Based on this Lyapunov function, a control law is derived to preserve the ISS properties of the system and improve its performance. A robustness analysis with respect to disturbances and estimation errors in the distributed parameters is performed on the system, precisely showing the impact of the controller on the rate of convergence and ISS gains. This is important in light of a possible implementation of the control since, in most cases, diffusion coefficient estimates involve a high degree of uncertainty. An application to the safety factor profile control for the Tore Supra tokamak illustrates and motivates the theoretical results. A constrained control law (incorporating nonlinear shape constraints in the actuation profiles) is designed to behave as closely as possible to the unconstrained version, albeit with the equivalent of a variable gain. Finally, the proposed control laws are tested under simulation, first in the nominal case and then using a model of Tore Supra dynamics, where they show adequate performance and robustness with respect to disturbances.