The prevention of access by infecting organisms to the locus of potential infection.