Sometimes when booking a trip you can be very flexible with many factors but any route passing through a certain country cannot be considered.
Say you're going from country A to country B either direct or not, but if not direct must not be via country C. But any city in any airport in both countries is fine, especially when the ticket is cheaper and you don't have a specific itinerary.
For instance if you're from a country where you would need a visa even to pass through one other country who has some of the common hubs between your origin and destination. Say if that country's visa is difficult to obtain given your nationality or something like overstaying in the past, or just having strict requirements you couldn't easily meet. Like if you're from a poor country going to another poor country but an intermediate rich country needs you to prove your finances, employment, etc that your destination is not too bothered with.
I'm not aware of a flight search engine which lets you specify a country or countries not to pass through along the way.
Is there a search engine I don't know about that has this feature? If not, is there another way to search for flights given this constraint using the usual flight search engines along with some trick or method that might not be totally obvious?