This is the first installment of the "exercises for injuries" series coming in the next few weeks. Here we describe how to make modifications to ensure that the stretch and position is not painful, and that you are maintaining erect posture and not slumping while you exercise.
Make sure to be actively stretching; the mobility gains are much more likely to last if you are using your muscles into the end range position as opposed to just passively holding it there. Passive stretching does very little to nothing to change mobility, we should all be avoiding doing it at all. The specific cues to make this position an active stretch are "push your ankle and knee into the floor" -- alternate that with "pulling your body over your leg while pushing your sit bone backwards and upwards." That's pushing actively into anterior pelvic tilt for those of you who know what that is. Hold each direction about 5 seconds for 5 reps each, and do 3 sets on each leg.