First, and most importantly, when recovering from an injury, don't rush it. It's hard to wait, but you must pay attention to the pain. If it hurts, don't do it. Doing too much too soon only leads to overuse and re-injury.
Second, do what you CAN. If you can't do what you usually do, do what you CAN do. Find a form of exercise that works for where you are right now, and use the parts of your body that you're able to use.
Third, if it really hurts, see a doctor. If it's low-grade, nagging pain that doesn't go away within a week or two, see a doctor. If you've lived with it for years and never bothered to check it out, see a doctor. And then follow his/her instructions.
An orthopedist or doctor who specializes in physical and rehabilitative medicine (a physiatrist - fizz-EYE-a-trist) can determine if you have an injury or fracture, a musculo-skeletal problem that can be treated with physical therapy, or a more serious medical condition such as a herniated disk. And sometimes pain in one area stems from a problem in another.
For me, it all started after grad school, when I moved to New York in the mid-90s. I had started jogging and practicing yoga in grad school to combat the weight creep I'd started to notice.
After moving to the city, I continued to jog, but my knees couldn't take the pounding. They've been painful on and off since adolescence and I decided it was time to get them looked at.
The orthopedist pronounced them "poorly constructed" by nature, diagnosed runner's knee and gave me a set of exercises to do using leg-extension and leg-curl machines at the gym to build muscle stability around the joint. No more running or lunges allowed (so much for my exercise videos, which were full of lunges).