How did cities in the desert with no rivers like Jerusalem or Riyadh come to be? Surely it seems pointless to build in such land?

by Forkgoesontheleft
GaulzeGaul

Any idea why Petra came into existence so far from an ideal location?