A generalized Villain formula is introduced. In this general Gaussian approximation, the topological properties of the electromagnetic loop for compact QED in four dimensions with an action which is the admixture of two terms with any different periodicities are investigated. The common properties of the phase structure, including two kinds of different partial confinement phases and a two-photon phase, of this model in the whole parameter space are discussed. By using the modified Migdal-Kadanoff group transformation, the phase diagrams for the cases of (N1, N2) = (l,5), (1,6), (1,7) are obtained. The numerical results are consistent with the theoretical analysis.