In my mid 30's (mid 50's now) I was able to go to a gym daily, spending the first hour on weights (machines, not free weights) and another hour on aerobics and stretching (I was the odd immovable character in the corner of the room who grunted a lot).
During that golden time, I was able to go completely off NSAIDs and took two aspirin once a day. Work and life changes then sent me to a decade of long plane rides and no work-outs, and I was back to square one, popping NSAIDs, in constant pain, and fast losing mobility.
Now that I am semi-retired and in a physically demanding job, the exercise is once again providing some relief.
I think that the worst medical advice I received when first diagnosed in the late 70's was to avoid weights and sports and only do stretching. But the fact is that strong muscles, especially stomach, lower back and chest, help remove weight from your bones when standing, help maintain an erect posture and IMO is key to better living under AS. Secondly, toned muscles are far easier to stretch than those out-of-shape, so strength training coupled with stretching is the way to go.
I have also constantly moved everything that hurts every day ever since I was diagnosed. Cases and severity of AS differ, but the result in my case is that I am fairly mobile (for AS) and only have total fusion in my lower spine. The trade-off is that all my joints, from neck to back to ribs to wrists, elbows and knees all hurt all the time. Pain management then consists of hot shower, exercise, and the lowest dose of NSAIDs I can get away with.