Dehydration occurs when the body loses water and essential salts (like sodium and potassium). This principally occurs through sweating, as both the water and the salts are lost this way.
The resulting chemical shifts in the blood are something the brain is very sensitive to, and the nerves there may interpret them as a headache
Similarly, if you lose enough water, your blood volume will drop and this will temporarily lead to lower blood and oxygen flow to the brain. When this occurs, blood vessels in the brain will dilate, which can cause some swelling and further worsen the feeling of headache.
The headache associated with dehydration may occur in the back of the head and neck or may be all over the head. It tends to get worse when you bend over.
Although you have tried to stay hydrated to prevent this, it is likely that you are still not drinking enough, as you are still getting headaches. You should try increasing even more the amount of water you drink, and you may also want to protect yourself from the sun with an umbrella or by standing in the shade.
Talk to your primary care doctor
if you have more questions!