We investigate the quantum interference effect of single photon transfer in a two-atom cavity system caused by the excitation phase. In the proposed system, the two identical atoms are firstly put into a timed state by an external single photon field. During the excitation, the atoms grasp different phases which depend on the spatial position of the atoms. Due to the strong resonant interaction between the atoms and optical cavity mode, the absorbed input photon can be efficiently transferred from the atoms to the cavity mode. We show that photon transfer is sensitive to the quantum interference caused by the excitation phases of atoms. The atomic positions can also determine the coupling constants between the atoms and cavity mode as well as the interatomic dipole–dipole interaction which causes additional interference effects on the quantum transfer. Based on the characteristics of the excitation phase, we find that it is a feasible scheme to generate a long-lived dark state and it could be useful for storage and manipulation of single photon fields by controlling the excitation phase.