Taking a rectangular path about which to evaluate Ampere's Law
the length of the side parallel to the solenoid field is L gives a contribution BL inside the coil.
The field is essentially perpendicular to the sides of the path, giving negligible contribution.
If the end is taken so far from the coil that the field is negligible, then the length inside the coil is the dominant contribution.