When you've become dehydrated and have a dehydration headache the first thing you should do is drink some water.
Hydrating yourself is the best way to help get rid of a dehydration headache since the dehydration headache is a result of being dehydrated.
Most dehydration headaches will resolve themselves within 3 to 4 hours of drinking the water and getting re hydrated.
The best thing to do to prevent dehydration headaches is to stay hydrated in the first place and make sure to drink some water, tea, juice etc even when you're not actually thirsty.
Drink something throughout the day and don't wait until you're thirsty as getting dehydrated can be serious enough to kill you.
If you are severely dehydrated you need to seek medical attention and call 911 if needed.