In this paper, a generalized manner is developed for the problem of the scattering of H-polarized electromagnetic waves from a shallow cavity with an arbitrary profile. Considering a proper auxiliary border and employing the region-matching technique, some close-form expressions are derived to compute the fields inside and outside the cavity. Next, we apply this approach to two cavities with different shapes and verify it by the Method of Moments (MoM).