Buddha was enlightened. He had transcended all man-made dogma and injunctions. Christians and Muslims today would do well to emulate him.
Just so, he had tried all kinds of extreme ascetic practices in his early days and almost died from starvation. Then he saw the light and preached the Middle Way.