Wavefront shaping with liquid-crystal spatial light modulators (LC-SLMs) is frequently hindered by a remaining fraction of undiffracted light, the so-called "zero-order." This contribution is all the more detrimental in configurations for which the LC-SLM is Fourier conjugated to a sample by a lens, because in these cases this undiffracted light produces a diffraction-limited spot at the image focal plane. In this Letter we propose to minimize two-photon (2P) excitation of the sample, resulting from this unmodulated light, by introducing optical aberrations to the excitation beam. Aberrations are subsequently compensated by the LC-SLM, but only for the modulated part of the beam, and not for the zero-order component. In order to experimentally demonstrate the method, we use astigmatism as the optical aberration, by simply adding one or two cylindrical lenses in the optical path of the beam. A 10⁴ decrease in zero-order-induced 2P fluorescence intensity is demonstrated. Combining this approach with temporal focusing is shown to decrease zero-order fluorescence by a factor of 4·10⁶.