Supernova remnants (SNRs) provide insights into cosmic-ray acceleration and magnetic field dynamics at shock fronts. Recent X-ray polarimetric measurements by the Imaging X-ray Polarimetry Explorer (IXPE) have revealed radial magnetic fields near particle acceleration sites in young SNRs, including Cassiopeia A, Tycho, and SN 1006. We present here the spatially resolved IXPE X-ray polarimetric observation of the northwestern rim of SNR RX J1713.7–3946. For the first time, our analysis shows that the magnetic field in the particle acceleration sites of this SNR is oriented tangentially with respect to the shock front. Because of the lack of precise Faraday rotation measurements in the radio band, this was not possible before. The average measured polarization degree (PD) of the synchrotron emission is 12.5% ± 3.3%, lower than the one measured by IXPE in SN 1006, comparable to the Tycho one, but notably higher than the one in Cassiopeia A. On subparsec scales, localized patches within RX J1713.7–3946 display a PD of up to 41.5% ± 9.5%. These results are compatible with a shock-compressed magnetic field. However, in order to explain the observed PD, either the presence of a radial net magnetic field upstream of the shock or partial reisotropization of the turbulence downstream by radial magnetohydrodynamical instabilities can be invoked. From comparison of PD and magnetic field distribution with γ-rays and 12CO data, our results provide new inputs in favor of a leptonic origin of the γ-ray emission.