When you slip into bed at night, you probably go straight to your favorite sleep position—perhaps on your side or on your back. But sleep positions can sometimes be tricky. Certain positions can help—or worsen—common health problems.

The best—and worst—sleep positions for seven common ailments…

SHOULDER PAIN

Sleeping on your back is often a good option if you have shoulder pain. To avoid compressing shoulder nerves, tendons and/or joints, make sure that your head, neck and shoulders are in a neutral position. Put a small pillow under your head (with a rolled-up towel under your neck, if needed). You may even want to put a small towel roll or pillow under your shoulder to give it more support, if needed.

Should you sleep on your side when your shoulder hurts? And if so, which side? It depends on the cause of your shoulder pain.

For sprains and rotator-cuff injuries: When opting for side-sleeping, most people with this type of shoulder pain are most comfortable hugging a pillow with the painful shoulder up.

Some people, however, are more comfortable—and hurt less in the morning—if they sleep with the painful side down. The joint will be supported by the mattress, and your weight will keep the affected shoulder from moving. Just be sure to place a pillow in front of your chest and under the painful shoulder for support.

For arthritis: The irritation and inflammation can worsen if you sleep on the painful shoulder. Keep pressure off the affected joint by lying on your back or on the other side with the arm supported by hugging a pillow.

KNEE PAIN

Do not lie on your stomach if you have knee pain—whether it’s from arthritis, an injury or a surgical procedure. The pressure on the kneecap can be painful. Also, people who sleep on their stomachs often stretch out the back of the knee joint. This can cause an overextension of the hamstring and the knee joint, leading to pain in the knee or hamstring.

Better: Sleep on your side with a pillow between your knees. The pillow should be thick enough so that the top leg remains in alignment with the hip. This prevents the top hip from dropping down, which can stress the leg and the spine. The pillow reduces friction and pressure on the knees and keeps the legs in proper alignment.

Another choice: Sleep on your back. You may want to sometimes use a small pillow or towel roll under your knees. Caution: If you have arthritis or any acute injury and use a pillow in this way often, it can increase swelling in your knees and limit the knees’ range of motion. For this reason, you might need to alternate between side-lying and sleeping on your back throughout the night or on different nights.

BACK PAIN

Back-sleeping is a good position for people with back pain. However, if you’re lying flat on your back, you may feel more comfortable with a pillow under your knees. This will keep your back in a more natural position and eliminate an excessive arch between your lower back and the mattress.

Self-test: If you can easily slip your hand into an open space between your lower back and the mattress, raise your knees a little more. Your lower back should be flat against your hand.

For back pain, you may also find it comfortable to sleep on your side with a pillow between your legs.

NECK PAIN

If your neck is tight and/or painful, do not sleep on your stomach. Reason: Unless you sleep with your face pressed into the mattress, you’ll need to turn your head to the side. This puts a lot of stress on the neck joints as well as the muscles and soft tissues in the neck and upper back.

Better: Sleep on your side with a pillow under your neck. The pillow should fill the distance between your neck and shoulder. You can use a special pillow for side- sleeping with more support for your neck and a cutout for your head (available online or from home-goods stores). Alternately, you can use a rolled-up towel to give your neck more support. You also can sleep on your back as long as you don’t prop up your head too high, which will strain your neck. (Usually one pillow is enough.)

FOOT PAIN

If you have extreme pain on the sole of your foot, you may have plantar fasciitis. This condition causes painful inflammation of the tissues on the bottom of the foot. If you have plantar fasciitis, it will likely worsen if you sleep on your stomach. Reason: You generally point your feet when you’re on your stomach. This shortens the muscles of the calf and soles of the feet and can cause painful cramps.

You will do better if you sleep on your back or side using a pillow between the legs. If you must sleep on your stomach, at least hang your feet over the end of the bed so that your feet and ankles are in a more neutral position.

SNORING AND SLEEP APNEA

Even people who do not usually snore will often do so when they sleep on their backs. Gravity pulls downward on the tongue and other structures in the throat, partially blocking airflow and causing snoring.

Sleeping on your back also can cause obstructive sleep apnea, in which breathing intermittently stops and starts during sleep. If you’ve been diagnosed with sleep apnea or if your partner reports that you gasp, snore or snort during sleep, try sleeping on your side or stomach. If you are on your side but tend to flip onto your back during the night, place a pillow or two behind you. This will stop you from rolling onto your back.

ACID REFLUX

If you suffer from heartburn, also known as acid reflux, how you sleep can determine whether you’re comfortable or suffering from that unpleasant “burning” sensation. Lying flat on your back makes it easier for stomach acid to surge upward into the esophagus—the cause of heartburn.

You’ll feel better if you elevate the upper half of your body with a wedge pillow, often made of foam. There are also special pillows that slip between the box spring and mattress (or under the mattress on a platform bed) to elevate the head of the bed. Risers for the head of the bed also can be used.

If you have heartburn: Sleeping on your left side often is advised. In this position, the esophagus is higher than the stomach to help prevent the backwash of stomach acid.

HOW TO CHANGE HOW YOU SLEEP

Suppose that you are a side-sleeper, but you know that you should be sleeping on your back. Before you go to sleep, think about the position that you want to maintain and start in that position. Remind yourself of this whenever you happen to wake up and return to the desired position.

It may take a few weeks (or even months), but the mental reminders and time in the desired position will eventually change the way that you sleep most of the time.

IS IT TIME TO REPLACE YOUR MATTRESS?

If you can’t remember when you bought your mattress, you’re probably due for a new one. Mattresses start to sag and lose their support after about eight or 10 years.

Choose a mattress that’s on the firm side or firm but with some cushioning on top, such as a plush-top mattress. About every three months, rotate the mattress. Flip it over if it has two sleep sides.

Also: Invest in more pillows. You can use them in different ways when you need more support or padding—for example, between your legs, for hugging and under your knees. Depending on the size of the pillows, two to four will generally be enough to provide added support for your body.