Kitzur Shulchan Aruch Chapter 11 Paragraph 2
The Laws of Mezuzah
סעיף ב גַּם שַׁעֲרֵי חֲצֵרוֹת וּמְבוֹאוֹת וַעֲיָרוֹת וּמְדִינוֹת, חַיָּבִין בִּמְזוּזָה, שֶׁנֶּאֱמַר, וּבִשְׁעָרֶיךָ (ועיין לקמן סעיף טז
Also, the gates of courtyards, streets, cities, and provinces are required to have mezuzot, as the Torah states: “and on your gates.”
Upon Your Gates
“Gateways” are radically different than the doors of houses. A gateway to a province may be an isolated structure straddling a main road, without any walls to its side. In fact, Rashi gives an example of such a provincial gate that is surrounded by the wilds of a forest.
Likewise, city gates may or may not be part of a walled enclosure. The Rishonim question how the gates into these areas would deserve mezuzah placement since they do not meet the basic conditions outlined in our introduction.
Rabbeinu Asher opines that the Torah obligates gateways to these areas according to their own norms, which are obviously different from the criteria pertinent to houses. For example, he explains that a ceiling is a necessary feature of a house, but not of a courtyard.
In contrast, Rambam maintains that gates into these areas do not qualify for mezuzah placement in their own right. They only need mezuzot when they lead ultimately to a dwelling.