Chaos is generally considered a nuisance, inasmuch as it prevents long-term predictions in physical systems. Here, we present an easily accessible approach to undo deterministic chaos in arbitrary two-dimensional optical chaotic billiards, by introducing spatially varying refractive index therein. The landscape of refractive index is obtained by a conformal transformation from an integrable billiard. Our study shows that this approach is robust to small fluctuations. We show further that trajectory rectification can be realized by relating chaotic billiards with non-Euclidean billiards. Finally, we illustrate the universality of this approach by extending our investigations to arbitrarily deformed optical billiards. This work not only contributes in controlling chaos, but provides a novel pathway to the design of billiards and microcavities with desired properties and functionalities.