Perovskite solar cells based on two-dimensional/three-dimensional (2D/3D) hierarchical structure have attracted significant attention in recent years due to their promising photovoltaic performance and stability. However, obtaining a detailed understanding of interfacial mechanism at the 2D/3D heterojunction, for example, the ligand-chemistry-dependent nature of the 2D/3D heterojunction and its influence on charge collection and the final photovoltaic outcome, is not yet fully developed. Here we demonstrate the underlying 3D phase templates growth of quantum wells (QWs) within a 2D capping layer, which is further influenced by the fluorination of spacers and compositional engineering in terms of thickness distribution and orientation. Better QW alignment and faster dynamics of charge transfer at the 2D/3D heterojunction result in higher charge mobility and lower charge recombination loss, largely explaining the significant improvements in charge collection and open-circuit voltage (VOC) in complete solar cells. As a result, 2D/3D solar cells with a power-conversion efficiency of 21.15% were achieved, significantly higher than the 3D counterpart (19.02%). This work provides key missing information on how interfacial engineering influences the desirable electronic properties of the 2D/3D hierarchical films and device performance via ligand chemistry and compositional engineering in the QW layer.