Photoluminescence and photoreflectance measurements have been used to determine excitonic transitions in the ternary AlxGa1−xAs alloy in the temperature range from 2 to 300 K. The effect of the thermal expansion contribution on the temperature dependence of excitonic transitions for different aluminum concentrations in the AlxGa1−xAs alloy is presented. Results from this study have shown that the negative thermal expansion (NTE) in the AlxGa1−xAs alloy, in the low temperature interval, induces a small blueshift in the optical transition energy. In the temperature range from ∼23 to ∼95 K there is a competition between the NTE effect and the electron-phonon interaction. Using the thermal expansion coefficient in the 2 -300 K temperature range, the thermal expansion contribution to GaAs, at room temperature, represents 21% of the total shift of the excitonic transition energy. After subtracting the thermal expansion contribution from the experimental temperature dependence of the excitonic transitions, in the AlxGa1−xAs alloy, the contribution to the electron-phonon interaction of the longitudinal optical phonon increases, relatively to the longitudinal acoustical phonon, with increasing Al concentration.