This study presents a novel investigation into the vortex dynamics of flow around a near-wall rectangular cylinder based on direct numerical simulation at
$Re=1000$, marking the first in-depth exploration of these phenomena. By varying aspect ratios (
$L/D = 5$,
$10$,
$15$) and gap ratios (
$G/D = 0.1$,
$0.3$,
$0.9$), the study reveals the vortex dynamics influenced by the near-wall effect, considering the incoming laminar boundary layer flow. Both
$L/D$ and
$G/D$ significantly influence vortex dynamics, leading to behaviours not observed in previous bluff body flows. As
$G/D$ increases, the streamwise scale of the upper leading edge (ULE) recirculation grows, delaying flow reattachment. At smaller
$G/D$, lower leading edge (LLE) recirculation is suppressed, with upper Kelvin–Helmholtz vortices merging to form the ULE vortex, followed by instability, differing from conventional flow dynamics. Larger
$G/D$ promotes the formation of an LLE shear layer. An intriguing finding at
$L/D = 5$ and
$G/D = 0.1$ is the backward flow of fluid from the downstream region to the upper side of the cylinder. At
$G/D = 0.3$, double-trailing-edge vortices emerge for larger
$L/D$, with two distinct flow behaviours associated with two interactions between gap flow and wall recirculation. These interactions lead to different multiple flow separations. For
$G/D = 0.9$, the secondary vortex (SV) from the plate wall induces the formation of a tertiary vortex from the lower side of the cylinder. Double-SVs are observed at
$L/D = 5$. Frequency locking is observed in most cases, but is suppressed at
$L/D = 10$ and
$G/D = 0.9$, where competing shedding modes lead to two distinct evolutions of the SV.