This is the wall hamstring stretch. This is an advanced stretch, good for pain or injury. This is best for the end phases of healing and physical therapy, and is not suitable for those in acute pain.
You're going to begin by lying down on your back with one leg straight up against a wall, or a couch. Your stabilizing leg can be bent, or, if it's comfortable, you can begin to straighten that leg.
Now, if achieving this stretch is difficult, you can start with a microbend in your leg and slowly work your way into straightening your leg. You can also begin with your seat further away from the wall, resting your leg at a height that's comfortable for you. And once that becomes easier for you, you can slowly scoot your seat closer to the wall.