Ruling on passing through places of evil
Question

                What is the ruling on passing through places of evil, such as cafes and the like, but not sitting in them, whether that is for an essential need or otherwise? If I am going someplace, do I have to look for a route in which there are no evils, even if that leads to taking a longer route to reach that place, or is that a kind of going to unnecessary lengths?
Praise be to Allah.Firstly:
Enjoining what is right and forbidding what is wrong is one of the greatest teachings in Islam, through which both religious and worldly affairs will be maintained in good order.
Al-Ghazaali (may Allah have mercy on him) said in Ihyaa’ ‘Uloom ad-Deen (2/306):
Enjoining what is right and forbidding what is wrong is one of the greatest principles in Islam and is the mission with which Allah sent all the Prophets. If no attention is paid to it and if people neglect to learn about it and put it into practice, then the teachings of the Prophet would be abandoned, religious commitment would be diminished, heedlessness would spread far and wide, misguidance and ignorance would become widespread, corruption would affect everything, order would begin to deteriorate, ruin would prevail throughout the land, and people would be doomed,  but they would not realise that they are doomed  except on the Day of Judgement. End quote.
For more information, please see the answer to question no. 96662.
Secondly:
There is nothing wrong with passing through places of evil, such as cafes and the like, so long as you do not join them in their falsehood.
Allah, may He be exalted, says (interpretation of the meaning):
“And [they are] those who do not testify to falsehood, and when they pass near ill speech, they pass by with dignity”
[al-Furqaan 25:72].
At-Taahir ibn ‘Ashoor (may Allah have mercy on him) said in at-Tahreer wa’t-Tanweer (19/79):
What is meant by passing by with dignity is that they pass by in an honourable manner, i.e., they do not join in with the ill speech or idle talk that is taking place there, for when the foolish pass by ill speech or idle talk, they like the atmosphere, and they pause for a while and join them in their idle talk. So if they do that, they are not acting in a dignified or honourable manner.
What is meant by dignity is keeping away from bad things and adhering to good characteristics; the opposite of that is meanness and vileness. The root meaning of karaamah (translated here as dignity) is that which is honourable and good.
If people of dignity come near those who are engaged in ill speech or idle talk, they refrain from joining them, and they pass by their place of gathering (without stopping to join them); thus they remain in a state of dignity.
This is praise for the believers who rise above what people used to do during the Jaahiliyyah. It is similar to the verses in which Allah, may He be exalted, says (interpretation of the meaning):
“And leave those who take their religion as amusement and diversion…”
[al-An‘aam 6:70]
“And when they hear ill speech, they turn away from it and say, ‘For us are our deeds, and for you are your deeds. Peace will be upon you; we seek not the ignorant’”
[al-Qasas 28:55].
End quote.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked:
, I pray and do all my religious duties, but in the marketplace there are unveiled women and I see them. Is there any sin on me or not?
He (may Allah have mercy on him) replied:
Undoubtedly the appearance of women unveiled in the marketplaces is an evil which the one who sees it must try to change with his hand (by taking action); if he cannot do that, then with his tongue (by speaking out); if he cannot do that, then in his heart (by despising it). Those who are in charge of the Muslims’ affairs must prevent women from going out unveiled to the marketplaces, because of the fitnah (temptation) that is involved in that, and because it causes a great deal of trouble for the women themselves.
If you pass through the marketplace, and you are not able to change this evil, then there is no blame on you, if you do what is required of you of these levels of trying to change the evil, by taking action, and if you cannot do that then by speaking out, and if you cannot do that then by despising it in your heart. But you should not look deliberately at these unveiled women, for a glance is one of the poisoned arrows of Iblees; whoever refrains from that out of hope for that which is with Allah and out of fear of Him, Allah, may He be blessed and exalted, will compensate him with sweetness of faith that he will find in his heart. Allah, may He be exalted, says (interpretation of the meaning):
“Tell the believing men to reduce [some] of their vision and guard their private parts. That is purer for them. Indeed, Allah is Acquainted with what they do”
[an-Noor 24:30].
End quote.
Fataawa Noor ‘ala ad-Darb by al-‘Uthaymeen (24/2).
If you are able to change your route and go via another route in which these evils are not found, or in which they are less than in your usual route, without causing yourself undue hardship or going to extra trouble, then that is better for you, and will make it more unlikely that you will see those evils and get used to them.
And Allah knows best.