© 2017 American Physical Society. With infrared (IR) ellipsometry and dc resistance measurements, we investigated the photodoping at the (001) and (110) surfaces of SrTiO3 (STO) single crystals and at the corresponding interfaces of LaAlO3/SrTiO3 (LAO/STO) heterostructures. In the bare STO crystals, we find that the photogenerated charge carriers, which accumulate near the (001) surface, have a similar depth profile and sheet carrier concentration as the confined electrons that were previously observed in LAO/STO (001) heterostructures. A large fraction of these photogenerated charge carriers persist at low temperature at the STO (001) surface even after the ultraviolet light has been switched off again. These persistent charge carriers seem to originate from oxygen vacancies that are trapped at the structural domain boundaries, which develop below the so-called antiferrodistortive transition at T∗=105K. This is most evident from a corresponding photodoping study of the dc transport in STO (110) crystals for which the concentration of these domain boundaries can be modified by applying a weak uniaxial stress. The oxygen vacancies and their trapping by defects are also the source of the electrons that are confined to the interface of LAO/STO (110) heterostructures, which likely do not have a polar discontinuity as in LAO/STO (001). In the former, the trapping and clustering of the oxygen vacancies also has a strong influence on the anisotropy of the charge carrier mobility. We show that this anisotropy can be readily varied and even inverted by various means, such as a gentle thermal treatment, UV irradiation, or even a weak uniaxial stress. Our experiments suggest that extended defects, which develop over long time periods (of weeks to months), can strongly influence the response of the confined charge carriers at the LAO/STO (110) interface.