The photoluminescence from semiconductor alloys is inhomogeneously broadened due to alloy disorder. We present a model to explain the so-called “S-shape” temperature dependence of peak position, taking into account recombination of free excitons and excitons bound to impurities. We find the following effects to contribute with increasing temperature: exciton localization on impurities at low temperatures, exciton transfer between impurities, exciton ionization from impurities, transfer of excitons between potential minima in the disorder potential, and shrinkage of band gap. We extend the common theory of ionization of excitons from impurities to take into account impurity ionization. We find this effect essential for our lineshape theory. The lineshape theory describes quantitatively the temperature dependent peak position in MgxZn1−xO alloys.