A novel porous Z-scheme Ag/AgFeO2/g-C3N4 (AAF/UPCN) photocatalyst was successfully prepared via a facile hydrothermal, precipitation and photo-deposition–method. Under visible light irradiation, AAF/UPCN exhibited excellent bisphenol A degradation effect and Staphylococcus aureus inactivation effect compared with porous g-C3N4 (UPCN) and AgFeO2. The •O2‾ was the major active species during the photocatalytic degradation process. For the photocatalytic mechanism, the photoexcited electrons of UPCN transferred to AgFeO2 mediated by Ag nanoparticles. This charge migration and separation route was verified collectively by the PL spectra, photoelectrochemical characterizations, chemical scavenger experiments and ESR measurements. Furthermore, the band distribution of catalysts was obtained by DFT calculation. This Ag nanoparticles mediated electron transfer pathway could promote the effective segregation of photoexcited carriers. The synergistic effect of UPCN, AgFeO2 and Ag in heterostructure could promote the efficient separation of photogenerated charge carriers. This study provides a new strategy for rational design of high-efficient g-C3N4-based photocatalysts for environmental remediation.