A recent spectrum of the optical afterglow of GRB 970508 suggests that gamma-ray bursts (GRBs) are cosmological in origin, and it is of crucial importance to derive an accurate distance to each burst. If GRBs occur near their host galaxies (<<40 kpc) then Lyman limit absorption [N(Hi)>=1.6x101̂7 cm2̂] should be observable in roughly half the GRB afterglow spectra. Here we outline the methodology to obtain a redshift from the GRB afterglow spectrum using the recently installed Space Telescope Imaging Spectrograph (STIS) instrument on board the Hubble Space Telescope. A low-resolution spectrum with the Multi-Anode Microchannel Array (MAMA) detector gives complete spectral coverage over the wavelength range 1570-3180 Angstroms (near- ultraviolet: NUV) and 1150-1740 Angstroms (far-ultraviolet: FUV). Assuming that a Target of Opportunity observation is conducted soon (<åisebox-0.5ex 3 weeks) after a bright burst, a relatively small integration time (i̊sebox-0.5ex 3 orbits) would be sufficient to detect the Lyman limit over a wide redshift range (0.3<ri̊sebox-0.5ex z<rae̊box-0.5extextasciit ilde2.2). Detection (or non-detection) of the Lyman limit, in concert with ground-based observations of nearby galaxies and Mgii and Civ absorption lines, should provide meaningful constraints on the relationship of GRBs to galaxies.