To analyze the motion of gravity current, a common approach is to solve the hyperbolic shallow water equations (SWE) together with the boundary conditions at both the current source at far upstream (i.e., the constrained condition) and the current front at downstream margin (i.e., the front condition). The use of the front condition is aimed to take the resistance from the ambient fluid into account, because the ambient resistance is absent in the SWE. In the present study, we rederive the SWE by taking the ambient resistance into account and end up with the so-called modified shallow water equation (MSWE). In the MSWE the ambient resistance is given by a nonlinear term, so that the use of the front condition becomes unnecessary. These highly nonlinear equations are approximated by the perturbation expansion to the leading order, and the resultant singular perturbation equations are solved analytically by the inner-outer expansion approach. Results show that for constant-flux and constant-volume gravity currents, their outer solutions are exactly the same as the solutions obtained by solving the SWE with the front condition. The inner solutions give both the profile and the velocity of the current head and lead to the recovery of the front condition in a more general form. The combination of inner and outer solutions gives a composite solution for the whole current, which was called by Benjamin [J. Fluid Mech. 31, 209 (1968)] a "formidably complicated" task. To take the turbulent drag on the current into account, we introduce the semiempirical Chezy drag term into the MSWE and results agreed with experimental data very well. The MSWE can be extended for three-dimensional gravity currents, while the resultant equations become so complicated that analytical solutions might not be available.