There is no way to prevent ankylosing spondylitis.
The aim of treatment is to reduce joint pain and to prevent, delay or correct any damage or deformities of the spine and other joints.
Medications To reduce pain, stiffness and inflammation, you may be given nonsteroidal anti-inflammatory drugs (NSAIDs), such as aspirin, ibuprofen (Advil, Motrin and others) or naproxen (Aleve). These medications may help to control your pain so that you can continue normal activities and exercise as part of your treatment. If NSAIDs are not enough to control the pain, more powerful medications such as sulfasalazine (Azulfidine) or methotrexate (Folex, Methotrexate LPF, Rheumatrex) may be recommended. However, these medications may cause side effects, and you have to be monitored regularly while you are taking them. For example, people taking methotrexate should have blood tests of liver function every 8 weeks. The injectable medications, etanercept (Enbrel) and infliximab (Remicade) were recently approved for ankylosing spondylitis; another, adalimumab (Humira), may also be effective. Early studies suggest that these drugs may be much more effective than older drugs.
Daily Management Treatment usually includes physical therapy and exercise. A physical therapist will develop an exercise routine for you that probably will include range-of-motion and stretching exercises to help the spine remain flexible. Abdominal and back exercises can help you maintain good posture so you are less likely to stoop. Swimming is an especially good exercise because it may be easier to move stiff, painful areas in the water. Biking also tends to be a good exercise for people with ankylosing spondylitis. Avoid any activities that could put too much stress on your back. For example, jogging may cause back pain to become worse because jogging puts more pressure on spinal joints.
Hot baths, heat and massage can help to relieve pain. If you can, sleep on your back on a firm mattress and use a small pillow or none at all.