Calcium and magnesium in hard water react with shampoos that have soap in them to form an insoluble flim, sort of like a bathtub ring on your hair "yuck".
To prevent this film's formation, add white vinegar or lemon juice to your rinse water. The acids will break down soapy film.
Image via Wikipedia
For an occasional treat, use distilled mineral free water instead of tap water when you shampoo.