Switch to box squats. They force you to sit back more (onto the box), developing good squatting mechanics and putting the stress of the movement on your hips—where it should be—rather than on your knees. Instead of lunges, do reverse lunges, where you step backward to lower yourself. This helps keep your front shin vertical when lunging, preventing knee strain.
If your knees hurt, work your hamstrings more. Muscle imbalances can cause knee pain.