To prevent hamstring injuries, warm up properly before exercising, stretch regularly to maintain flexibility, and incorporate strength training exercises that target the hamstrings and glutes. If you experience a hamstring injury, rest, ice, compress, and elevate the affected leg, and consider seeing a physical therapist for exercises to rehabilitate and prevent future injuries.