In this paper we present BeppoSAX and XMM-Newton observations of two long gamma-ray bursts (GRBs), the X-ray - rich event of 2001 December 11 (GRB 011211) and the hard and very bright event of 2001 November 21 ( GRB 011121). In both events we find evidence of a late X-ray burst taking place several minutes after the prompt emission. In the November burst the spectrum of the X-ray burst is much softer than that of the preceding prompt phase and consistent with the spectrum of the afterglow at 1 day. In addition, the tail of the X-ray burst and the light curve of the afterglow at 1 day are connected by a single power law approximate to( t - t(0))(-delta x), when t(0) corresponds with the onset of the X-ray burst. These evidences suggest that the late X-ray burst represents the onset of the afterglow. A similar conclusion is drawn for the December burst. The temporal and spectral behavior of the X-ray and optical afterglows indicate that the fireball evolution in the December burst takes place in an interstellar medium ( ISM) environment. In contrast, in the November burst the wind case is revealed by an X-ray decay slower than that observed in the optical (delta(X) = 1.29 +/- 0.04 vs. delta(O) = 1.66 +/- 0.06). The wind profile should change into a constant-density profile at large radii in order to reconcile late-time radio data with a jet. Two other results are obtained for this burst. An X-ray burst precedes the much harder GRB by about 30 s. Contrary to the prediction of simple models of precursor activity for collapsars, the precursor's spectrum is not consistent with a blackbody. Finally, a substantial absorption column [N-H = ( 7 +/- 2) x 10(22) cm(-2)] is detected during the early part of the prompt emission. This is much greater than that of the wind, and it is thus likely associated with the region surrounding the burst.