What causes this?

A couple of days ago I was driving out to my mom's house and happened to be looking in the sky and noticed what looked to be like a rainbow, but on a partly cloudy day?


I know it has to do with the light spectrum and that sort, but was wondering if anything weather related causes this? Anyone else seen anything similar? Just curious is all.
I see sundogs fairly often, most often during cold winter days, although they do occur at any other times when there's a lot of high cloud present.

But the best ones I see usually occur on sunny winter days colder than -20°C (-4°F) to -30°C (-22°F) outside and there are a lot of ice crystals about, both at low and high altitudes. On days like these, you'll also get a host of other optical phenomena like halos and stuff, too.