With the safety concerns out of the way, I think one of the best exercises you can do for your legs when your goal is to target the quadriceps muscles but avoid any excess stress on your back is the machine leg press exercise. This is the machine that you sit in at about a 90 degree angle with your back almost completely straight up and down, and it has a stack of weights actually built into it where you can adjust the poundage by moving a pin to choose your desired resistance.
I want to make it clear that this leg press machine I’m describing should not be confused with the traditional 45 degree “sled” style leg press in which you have to manually add weighted plates onto and sit down into the machine at a 45 degree angle. This leg press “sled” is a fantastic piece of equipment for building up your legs, however it places way to much stress on your lower back when you lower your legs to the bottom position of the exercise, and with your current back issues it is definitely not an exercise you want to use in your routine to build up your legs.
For your hamstrings, I personally would not even think about touching stiff-legged deadlifts due to the potential issues with placing too much stress on your back. You should be able to get a great hamstring workout by using the traditional seated leg curl machine where you sit at a 90 degree angle with your back up against a protective pad. Your other options are the standing leg curl machine and the lying leg curl machine to really target your hamstrings very well without worrying about your back being stressed too much while you perform the movement.
With your current hernia and back condition, the most important thing you should be aware of when training is simply how you feel when you’re in the gym. Start off very light with any exercise just to be safe and see if you feel any stress or pain in the area where you have had prior problems. If you feel a sense of discomfort, then by all means, stop what you’re doing and choose a safer exercise that eliminates this unwanted stress. Your overall goal is to fully recuperate from your injuries so you can train pain free in the future. As hard as it might be to cut back on training or decrease the overall amount of weight used, the return on investment for this type of smart training with pay huge dividends down the road!