When we know that someone's behavior has nothing to do with us, it's easier not to take it personally: our significant other comes home upset after a bad day at work and is grouchy; our teenage kid is embarrassed when we try to hold their hand in public; etc. It's much harder to avoid taking things personally when we don't know the reason behind someone's behavior - or even worse, when the behavior seems to be about us.
Here's a secret...most of the time (almost ALWAYS), it's not really about us, even when it seems like it is. The way people treat us often has very little to do with who we are, and much more to do with who they are. If someone is rude or hurtful to you, attacks or criticizes you, abandons or betrays you it is not necessarily because you deserved it but, more likely, it's because that is how that person chooses to see you and the rest of the world around them.
I see people struggling with this every day. They have a very difficult time understanding why someone broke up with them, cheated on them, ended a friendship, abandoned them, etc, and they search endlessly to identify what they did to bring on that type of treatment. The truth is that they probably did very little. The person who hurt them likely behaves that way with many people.
If you're upset by someone's treatment of you, instead of taking it personally, try to see it as a reflection of how they feel about themselves and the world around them (read more about this here). Most likely you are just one in a long line of people they've been treating that way.