Herein, a magnetic molecular imprinted polymeric ionic liquid (MMIPIL) film was designed by using the functionalized ionic liquid (3-vinyl-4-amino-5imidazole carboxamide chloride, IL) and Fe 3 O 4 @Polyrutin-COOH as functional monomer and supporting materials. The change in the direction of the charge density in the structure of MMIPIL polymer resulted in a red shift about 100nm for the characteristic group of-C=O. Polyrutin containing electron-rich benzene ring and multiple hydroxyl groups not only prevented the aggregation of Fe 3 O 4 , but also benefitted to immobilize template molecules. The more symmetric amino groups in template molecules generated more hydrogen bonds and other synergistic effects between MEL and functional monomers, which resulted in a high-matched and high stable MMIPIL sensor. The proposed magnetic sensor lowered the matching potential, and enhanced the signal for the detection of melamine (MEL) in milk powder. Under the optimum conditions, the MEL template molecule showed a significant linear relationship between 5.0×10-3 and 0.8 µg/L with a detection limit (S / N = 3) of 1.5× 10-3 µg/L. The MMIPIL sensor showed wonderful selectivity and exhibited facile, fast and efficient results in the monitoring MEL with the recoveries between 96.5% and 108.3%.