The woman had taken the two men and had hidden them. She told the king's messengers, “Yes, it's true—the men did come to visit me, but I didn't know where they were from.
Then Elisha went and told them, “This isn't the right road, and this isn't the right town. Follow me, and I'll take you to the man you're looking for.” He led them to Samaria.
In the same way, wasn't Rahab the prostitute made right by what she did when she looked after the messengers and then sent them away by a different road?
So the king of Jericho sent orders to Rahab, telling her, “Hand over the men who came to visit you and stay in your house, for they've come to spy out our whole country.”
They left at sundown, just as the city gate was closing. I've no idea where they went. If you're quick, you can chase after them and maybe catch up with them.”
The city and everything in it is to be set apart for the Lord and destroyed. Only Rahab the prostitute and all those with her in her house shall be spared, because she hid the spies we sent.
Joshua spared Rahab the prostitute and her family because she hid the men Joshua had sent to spy out Jericho. And she lives among the Israelites to this day.