Depends on cause.
If the pain is mild and infrequent, stretching can be of great help.
Strengthening the paraspinal muscles then can help prevent some issues. Don't forget ice-followed-by-heat as treatment tools. If conservative tx not working, will need medical workup to determine if this is joint arthritis
vs. Disc related/stenosis (narrowing of the spinal openings).