Faced with the rapid growth of internet traffic demand, which has posed a huge challenge to the current fiber-based communications systems, expanding the telecommunications bands from traditional near-infrared (NIR) region to mid-infrared (MIR) region is emerging as an attractive solution. And on-chip wavelength division multiplexing (WDM) application for NIR/MIR wavelengths is an essential element in future optical telecommunication systems. Here, we propose a compact silicon-based polarization-independent wavelength diplexer for the NIR/MIR wavelengths of 1.55/2 μm, where multiple rectangular grooves are shallowly etched on the silicon MMI waveguide for introducing the refractive-index perturbations on the MMI waveguide eigenmodes. And this refractive-index perturbation scheme provides a simple and scalable method to manipulate the four beat lengths of the two wavelengths at TE- or TM-polarization in a single waveguide via self-imaging effect, leading to a compact footprint. By optimizing the structural parameters, both NIR/MIR wavelength demultiplexing and polarization independence, for the first time, are obtained simultaneously in the present single device. From the results, the proposed diplexer is only 21.6 μm in length, and shows a wide bandwidth of ∼ 100/120 nm around the wavelength of 1.55/2 μm for insertion loss (IL) < 1 dB and extinction ratio (ER) > 15 dB. Moreover, we also realize a compact and polarization-independent wavelength diplexer for 1.31/2 μm by flexibly changing the dimensions, showing the flexibility and extensibility of our refractive-index perturbation scheme. Besides, fabrication tolerances are analyzed and mode propagation profiles are also demonstrated.