Measure the height of the rim joist with a tape measure. Take another measurement on the face of the rim joist between each floor joist.
Cut pieces of rigid foam to your measurements with a utility knife. These pieces will fit against the face of the rim joist in between the floor joist. Repeat for the entire perimeter of the home. Cut the rigid foam as necessary to fit around pipes and other obstructions going through the rim joist.
Apply a bead of silicone caulk around the seam between the rigid foam and rim joist with a caulk gun. Caulk around all four sides of the foam where it meets the sill plate and floor joists.
Fill gaps between pipes and the rigid foam with spray expanding foam insulation. Spray the expanding foam insulation into seams between two pieces of rigid foam where you fit the foam around obstructions.