You can find a lot of great information online - search for "recovery nutrition".
There are two areas that are important:
First, you need to rehydrate, unless you are one of those rare people who actually drinks enough to stay hydrated on the ride.
Second, you need to replace your carbohydrate stores. There is a "golden window" after the end of exercise (about an hour or so) in which you will absorb carbohydrates more quickly. It can also be useful to get some protein at the same time. The research says that it doesn't matter whether you use real food to do this, or whether you use a recovery drink. My experience - and in these sort of things, people vary - is that recovery drinks work much better than real food. I like Endurox R4, though chocolate milk can be a cheap substitute if a) you tolerate lactose well and b) you can find a chocolate milk with sucrose rather than high fructose corn syrup.
Getting this right made the biggest difference in how much my legs hurt after long rides. It also helps control hunger after the ride, which is useful if you are trying to lose weight.