A coumarin-based viscosity-responsive fluorescent probe (HZAU800) was designed and synthesized. The probe, containing a strong electron-donating and rigid group on the 7-position of coumarin and a rhodamine derivative containing an oxonium ion on 3-position, could not only shift the emission wavelength to near-infrared region (NIR, λem = 800 nm) but also deliver a good PDT effect due to its high rigid planarity. The NIR fluorescence of HZAU800 can be lighted up in the S. aureus-infected region due to its high viscous environment. Under the laser's irradiation at 690 nm, the PDT effect was effectively triggered up, and the antibacterial evaluation in vitro and in vivo was successfully carried out. This study not only offers a new strategy for constructing coumarin-based phototherapy agents but also facilitates the exploration of the next generation of antibacterial materials based on coumarin architectures.