I think there are two steps:
1. Decide the character's philosophy of life
I'm using the example of two medieval characters because that's my settings of choice. Imagine we need two female characters: Eleonor is the lady of the manor and Mary is her twice-removed cousin (from a poorer branch of the family) who lives with her as a lady-in-waiting.
As the lady of the manor, Eleonor exerts strict authority over all who live in her property while her husband is away. Her authority comes from her husband, naturally (God did create the woman to be under her husband's authority). She has a good relation with her husband, but she's aware she's lucky and there are many women who are not as lucky. That means that the men in question are at fault and such wives should be helped if possible - but that would enver be an excuse for a wife to try and escape her lord and master!
Mary is aware she is a poor relative and is indebted to her older cousin and lady: all she has comes from her, after all. On the other hand, Eleonor is a kind soul and they both enjoy spending time together, with Mary helping her in what she can. She does have ambitions: to marry a worthy nobleman, for example, even if she wouldn't be so bold as to ask for someone above her position. In fact, that might be a bad option, as her husband's family would dismiss and even despise her for being below their standing.
2. Get inside their shoes
It is all very well to determine the character's philosophy in keeping with their times. But now it's time to write... and the author's feelings cannot shine through.
Let us start with Eleonor.
First step: Take a deep breath and close your eyes. You are no longer J. Doe: you are Lady Eleonor. Sit straight and level your head. With your eyes closed, visualise your garden (or wherever you are). Try and feel the air (hot or cold, dry or damp?), the smells, feel the dress pooling around your ankles.
Second step: Begin the scene.
Lady Eleonor smiled at her eight year old son, playing with the little servant boy. Her husband had brought the little boy as a slave from his latest battle against the Muslim Kingdom of Granada.
!!! Modern sensibility comes in: Slaves and religious intolerance. Yeah. Perfectly in tune with the times, I'm afraid. Harden yourself: having slave muslims was ok in medieval Europe (and common enough in the southern kingdoms). They could be black, dark skinned or perfectly white - it didn't matter. It was normal. Because Eleonor is a likeable character, her only concern will be about having the boy well-treated... according to his station. Resume:
"Mark," she called sharply when the little boy stuck a dirty finger in his nose. "That is not appropriate behaviour."
Slave or not, if he was to be a play companion of her son, he must behave courteously. But enough of play time! It was time for her son's lessons and she still had much work to do with little Mark. She'd had him baptised as soon as possible and was now making sure he understood the fundaments before Father Matthew started teaching him some Latin.
Let us move on to Mary.
First step: Take a deep breath and close your eyes. You are no longer J. Doe: you are Mary. Sit straight and turn your head slightly downwards. Once more, visualise everything around you.
Second step: Begin the scene.
Through the window of Lady Eleonor's chambers, Mary sees the young men honing their warrior skills. One of the younger ones, thinner than the rest, is once more being swarmed.
!!! Modern sensibility comes in: the boy is being bullied and Mary, as a sympathetic character, is going to decry and try to help him. Take a step back: while it's perfectly acceptable for the character to think that swarming is unfair, she would never dream of interfering: it would be humilliating to have a woman come in to his defense, and, as a woman, she has no right to meddle. Come to think of it, it would be natural for her to assume that being so often 'swarmed' was an appropriate way to help him improve, something like 'tough love'. Resume!
He was desperately outnumbered and, from what Mary could see, he was bound to end the practice all bruised. It upset her to see the scene - to her female eyes, the older boys seemed so violent! - but she was sure John would improve quickly. At least she hoped so. If only his father had wished him to become a clergyman... He was far more skilled at writing!
Last Resort Options
If fighting off modern sensibility is difficult, try to make parallels with something that is natural for you. You should also hang on as hard as you can to the logic that makes something evil nowadays an acceptable option at the time.
Torture, for example. Try to get inside the character and see torture as a sort of truth serum. Yes, you as the author know that torture doesn't guarantee truth as a person will say anything to stop it, but still, as the character, you know they would never own to that murder if they hadn't been tortured and everyone knows the criminal was the one who did it.
On the other hand, your character may feel that torture is only appropriate when one knows for sure who did the evil deed, and they may also feel that some types of torture are a bit too cruel.
If the lack of female freedom enrages you, hold on to that rage and turn it around: now what enrages you is those people who defile marriage. Those people destroy the community and bring down God's wrath on everyone! Sodom and Gomorrah, remember?
Better yet, do not focus on what women cannot do; focus on what they can do. If a woman can't choose her husband, what can she do to have some control? Maybe she can talk to her mother and see if she can put in a good word (at least to avoid someone she despises). Or maybe it's out of her hands and all she can do is... flirt a little behind her parents' back while she's still single.
Forcing a raped girl to marry her rapist sounds evil? Then keep in mind that to not do so means she will end up in prostitution. Maybe she'll end up murdered or sick. Her body sullied, her soul lost, and her honour destroyed. Yes, it is unfair, but far worse would be to not force that man to compensate her in the only possible.
Do not try to counter the logic and arguments of the past using your current knowledge, but if you must counter some ideas, use the arguments of the time. There were a couple of medieval saints who preached against the husbands who beat their wives, so being a medieval person doesn't mean that everyone agrees with domestic violence. Of course, violence at the time meant something far more drastic than nowadays: slapping the wife on occasion wasn't the problem, but beating her till she was unconscious was definitely not seen with good eyes.
While what I wrote focuses a lot on medieval times, the same is valid for any culture. Get inside that culture and find out how people think and feel. Remember that 'People are ok with X' doesn't mean that everyone in that culture accepts it whole-heartedly.
Even if the problematic worldview is not about a culture but a person - an abusive partner, for example - the author still has to understand how the character thinks and feels. Read accounts of real people (both abusers and abused) and understand their logic. Then get inside the characters' shoes and do not let your own consciousness slip onto the text
Remember: you are not J. Doe, the author. You are that character and their logic must come to the fore until the scene is written. Close your eyes and feel yourself become someone else.