Abstract. Magnetic clouds (MCs) are large-scale magnetic flux ropes ejected from the Sun into the interplanetary space. They play a central role in solar-terrestrial relations as they can efficiently drive magnetic activity in the near-Earth environment. Their impact on the Earth's magnetosphere is often attributed to the presence of southward magnetic fields inside the MC, as observed in the upstream solar wind. However, when they arrive in the vicinity of the Earth, MCs first encounter the bow shock, which is expected to modify their properties, including their magnetic field strength and direction. If these changes are significant, they can in turn affect the interaction of the MC with the magnetosphere. In this paper, we use data from the Cluster and Geotail spacecraft inside the magnetosheath and from the Advanced Composition Explorer (ACE) upstream of the Earth's environment to investigate the impact of the bow shock's crossing on the magnetic structure of MCs. Through four example MCs, we show that the evolution of the MC's structure from the solar wind to the magnetosheath differs largely from one event to another. The smooth rotation of the MC can either be preserved inside the magnetosheath, be modified, i.e. the magnetic field still rotates slowly but at different angles, or even disappear. The alteration of the magnetic field orientation across the bow shock can vary with time during the MC's passage and with the location inside the magnetosheath. We examine the conditions encountered at the bow shock from direct observations, when Cluster or Geotail cross it, or indirectly by applying a magnetosheath model. We obtain a good agreement between the observed and modelled magnetic field direction and shock configuration, which varies from quasiperpendicular to quasi-parallel in our study. We find that the variations in the angle between the magnetic fields in the solar wind and in the magnetosheath are anti-correlated with the variations in the shock obliquity. When the shock is in a quasi-parallel regime, the magnetic field direction varies significantly from the solar wind to the magnetosheath. In such cases, the magnetic field reaching the magnetopause cannot be approximated by the upstream magnetic field. Therefore, it is important to take into account the conditions at the bow shock when estimating the impact of an MC with the Earth's environment because these conditions are crucial in determining the magnetosheath magnetic field, which then interacts with the magnetosphere.