Hamstring pain while cycling
Have you been fitted on you bike ? It might be that your saddle is not a the appropriate height. More so if you have lower bike pain while cycling.

Some websites will provide bike fit measurement based on your body measurements (this one for example), you can start there. In general,  when the pedal is at 6 o'clock you want a slight bend in you knee (not fully extended, but not bent very much)

If that looks OK, I would check you pedaling technique, maybe you're doing something wrong there that creates pain.