The nanostructured rugate porous silicons (PSi) containing multiple photonic band gaps have been generated by an electrochemical etching through applying a composite waveform summed three computer-generated pseudo-sinusoidal current waveforms. They exhibit three sharp photonic band gaps in the optical reflectivity spectrum, corresponding to the each of the sine components varied from 0.42, 0.36, and 0.30 Hz, with a spacing of 0.06 Hz between each sine component. The sensing experiments using multi-encoded rugate PSi for the detection of nerve agents such as triethyl phosphate (TEP), diethyl chlorophosphate (DCP), dimethyl methylphosphonate (DMMP), and diethyl ethylphosphonate (DEEP) have been achieved. Capillary condensation in the pores causes the reflectivity of rugate PSi to shift to longer wavelengths due to an increase in refractive indices of the porous medium.