When my lower back is really bothering me, I fall asleep on my back with a pillow under my lower legs. It does usually help. It changes the angle of my hips and flattens my lower back, I think.

But I also prefer to sleep on my side, and I have a small temperpedic pillow that's peanut-shaped that I keep between my knees. It usually helps prevent hip pain. When my hips hurt anyway, it usually means I've been neglecting the piriformis stretches and the foam rolling on my quads.