A wavelength-encoding optical position sensor was designed in this study. The critical component of the sensor is its innovative digital encoding grating ruler (DEGR), which is a substrate on which several blazed grating units with different line densities are arranged parallel to one another following a certain order. Two types of multi-DEGR were designed. We obtained over 100,000 codes that significantly assisted in designing long-range and high-resolution position sensors by optimizing the coding algorithm. The wavelength signals generated by the multi-DEGR were demodulated using concave grating and several photosensitive elements. A 100-mm multi-DEGR with 1000 codes was successfully fabricated using the combined methods of direct laser writing and holographic technology. We described the principle of the sensor in detail and established the entire sensor system. A bench test was conducted to test the signal response of the sensor. Bench test results exhibited 100% accuracy of the signal response of the optical sensor and an excellent temperature performance within −55°C and 75°C.