The development of a simple, rapid, sensitive, and accurate method for detecting Escherichia coli O157:H7 in complex matrices is critical for ensuring food safety. In this study, a fluorescent biosensor employing aptamer (Apt) -functionalized magnetic beads and cascade strand displacement amplification (SDA) was devised for the detection of E. coli O157:H7 in milk samples. E. coli O157:H7 is captured by the aptamer, causing the complementary DNA (cDNA) to not bind to the aptamer and to be released into the supernatant. Following magnetic separation, the cDNA present in the supernatant initiates the opening of the hairpin (HP) structures. This enables primers to attach to the opened HP, triggering the initial SDA process, which generates a substantial quantity of double-stranded DNA (dsDNA) and recycles cDNA to open more HP structures. The dsDNA activates a second SDA, producing single-stranded DNA (ssDNA) for template binding and instigating a third SDA process. Triple SDA leads to the production of numerous G-quadruplex sequences and the formation of a G-quadruplex structure in the presence of K+. The inclusion of ThT into the G-quadruplex significantly enhances fluorescence. Under optimal conditions, this approach can detect E. coli O157:H7 at levels as low as 101 CFU/mL in pure cultures within 2.5 h, with a broad linear detection range of 101–106 CFU/mL. This method exhibits remarkable specificity towards the target bacteria over non-target bacteria. Furthermore, the technique has been effectively utilized for the detection of E. coli O157:H7 in milk samples. Notably, the method involves only two main steps, identification and amplification, significantly reducing contamination risks and minimizing operational steps.