As predicted by quantum chromodynamics(QCD), around T ∼ 190 MeV in the early universe, the QCD transition occurs during which the quarks are combined into the massive hadrons.This process reduces the effective relativistic degree of freedom, and causes a change in the expansion behavior of the universe. Similarly, the e + e − annihilation occurred around T ∼ 0.5 Mev has the same kind of effect. Besides, the dark energy also drives the present stage accelerating expansion. We study these combined effects on the relic gravitational waves (RGWs). In our treatment, the QCD transition and the e + e − annihilation, each is respectively represented by a short period of expansion inserted into the radiation era. Incorporating these effects, the equation of RGWs is analytically solved for a spatially flat universe, evolving from the inflation up to the current acceleration, and the spectrum of RGWs is obtained, covering the whole range of frequency > 10 −19 Hz. It is found that the QCD transition causes a reduction of the amplitude of RGWs by ∼ 20% in the range > 10 −9 Hz, and the e + e − annihilation causes a reduction ∼ 10% in the range > 10 −12 Hz. In the presence of the dark energy, the combination of the QCD transition and the e + e − annihilation, causes a larger reduction of the amplitude by ∼ 30% for the range > 10 −9 Hz, which covers the bands of operation of LIGO and LISA. By analysis, it is shown that RGWs will be difficult to detect by the present LIGO, but can be tested by LISA for certain inflationary models.