Others have good advice: none-cotton, tight underwear; balm or talcum powder; dry clothes.
However, I have one more option: when I'm on the move and start feeling chaffing in my bum, I'll do the moonwalk. The moonwalk is a technique for drying out one's nether regions while staying on the move (not this) This works best with the loose basketball shorts I usually wear, but can be done with other shorts or pants as well.
To do the moonwalk, stow away any trekking poles you have, drop your pants and underwear so that the waistband is below your butt cheeks (and crotch, if you're having problems there). Grab the crotch of your pants, and start hiking. Note that, for rashes between the legs or between the legs and groin, you will need to do a bit of a waddle.
Clothes - even light, breathable, wicking clothes - will trap moisture next to your skin. Under these conditions, the skin will absorb the excess moisture and weaken, making friction applied more damaging than usual. In order to solve this problem, we remove the moisture. This is why underwear made for hiking work at moving moisture away from the skin. This is also why talcum powder works, since it absorbs the moisture (which is why it feels cool when you apply it), moving it away from the skin's surface and allowing it to regain its strength.
The moonwalk works by removing the humid environment around the groin and providing air flow. Since the moisture is no longer trapped in a container of small volume around your groin, it will mix with the outside air to the point where the gradient of humidity around your groin approaches the step function. As the gradient becomes sharper, the rate of evaporation on your skin will increase, leading to drier skin and less chaffing.
The moonwalk has an advantage over other techniques in that it allows for the highest constant rate of evaporation, whereas breathable clothing will still limit this rate, and talcum powder will need to be periodically reapplied. Additionally, the moonwalk allows for convective heat loss as the atmosphere moves heat away from your body as it flows around you, and does not dampen radiative heat loss as other techniques do. This combination allows skin temperature to stay lower, which will elicit less of a response from the sweat glands, further reducing the moisture content of your skin.
Why not simply take your pants off, you may ask? Because, even on relatively lonely trails, there is a chance that other people will come upon you and, conforming to social standards, you will want them not to see your groin. The moonwalk allows you to quickly conceal your modesty when you see or hear others approach. Of course, an alternative may be to use a hiking skirt or kilt, but these will still trap some amount of moisture, and are not very popular - especially among male hikers.
I find I air out after about 10-15 minutes of moonwalking, and can pull my pants up after. Just make sure to watch out for strangers coming up the trail in front of or behind you!