Ladderlike optical conductivity in the spin-fermion model