The development of fluorescence sensing platforms with excellent photoluminescence capabilities is of great importance for their further application. In this work, a photonic crystal structure was successfully applied to enhance the luminescence performance of fluorescent hydrogel, and the application of the obtained hydrogel as a fluorescence sensor was explored. A polystyrene photonic crystal template was constructed via vertical deposition self-assembly; then, the precursor solution containing polyethylenimine-capped CdS quantum dots (PEI-CdS QDs) and monomers filled in the gap of the template. After the polymerization process, the desired hydrogel was obtained. PEI-CdS QDs endowed the hydrogel with its fluorescence property, while interestingly, the photonic crystal structure showed a significant enhancement effect on the fluorescence-emission capability. The mechanism of this phenomenon was revealed. Moreover, this hydrogel could be used as a reusable fluorescence sensor for the detection of nitrite in water with good selectivity. The limit of detection was determined to be 0.25 μmol/L, which is much lower than the maximum limit for nitrite in drinking water.