Can staying hydrated help alleviate headaches and other types of pain?

Can staying hydrated help alleviate headaches and other types of pain?