We present a direct, room-temperature near-field optical study of light confinement by a subwavelength defect microcavity in a photonic crystal slab containing quantum-well sources. The observations are compared with three-dimensional finite-difference time-domain calculations, and excellent agreement is found. Moreover, we use a subwavelength cavity to study the influence of a near-field probe on the imaging of localized optical modes.