Step 1: Meaning of the law.
Ampere's circuital law connects a magnetic field with the current that produces it. For any imagined closed path, adding up \(\vec{B}\cdot d\vec{l}\) all the way round gives \(\mu_0\) multiplied by whatever net current pierces the path: \(\oint \vec{B}\cdot d\vec{l}=\mu_0 I_{enc}\). It plays the same role for magnetism that Gauss's law plays for electricity and is most useful when the geometry is symmetric.
Step 2: Symmetry of a solenoid.
Picture a very long tightly wound coil with \(n\) turns in every metre carrying steady current \(I\). By symmetry the interior field is straight, axial and of one constant magnitude \(B\); just outside a long solenoid the returning field is spread over a huge region and is taken as zero.
Step 3: Build a rectangular path.
Draw a rectangle whose long arm (length \(\ell\)) runs through the interior parallel to the axis and whose opposite long arm lies well outside. The two short arms cross from inside to outside.
Step 4: Split the circulation.
Interior long arm gives \(B\ell\). On the short arms \(\vec{B}\) is at right angles to the path (and zero once outside), giving nothing. The outer long arm sits where \(B=0\), giving nothing. Hence the whole circulation is simply \(B\ell\).
Step 5: Count the linked current.
The rectangle of length \(\ell\) encloses \(n\ell\) turns, so the current linked is \(I_{enc}=n\ell I\).
Step 6: Equate and cancel.
\(B\ell=\mu_0 n\ell I\), and \(\ell\) cancels to leave \(B=\mu_0 n I\). The field is independent of the loop length and of position inside, confirming uniformity.
\[\boxed{B=\mu_0 n I}\]