Weathered rocks typically exist in the portal section of mountain tunnels where the tunnels in the portal section often cross soft and hard rock strata. The interface between the soft and hard rocks is the control point in the seismic design of tunnels. However, there is currently no seismic design method based on dynamic methods that consider tunnels crossing soft and hard rock strata along their longitudinal direction. In this study, two elastic foundation beams in different rock strata were used to model the behaviour of a tunnel crossing soft and hard rock strata. Based on the Timoshenko beam vibration response theory, the higher-order differentials of the beam dynamic governing equation are transformed into algebraic equations using the Laplace transform. The closed-form solution of the dynamic response of the entire beam is derived by combining the boundary and deformation coordination conditions of two elastic foundation beams. Subsequently, the dynamic response of any point along the longitudinal direction of the elastic foundation beam (tunnel) crossing the soft and hard rock strata was obtained using Green's function. The validity of the method was verified by comparing it with a finite difference model. Finally, a parametric analysis was performed based on the analytical method derived in this study to investigate the influences of parameters such as the liner elastic modulus, liner thickness, modulus of elasticity ratio of hard rock to soft rock, and axial forces, on the seismic response of tunnels crossing soft and hard rock strata. The results suggest that with an increase in lining thickness, the bending moment and shear force of the tunnel become increasingly significant, but the transverse displacement response of the tunnel was slightly affected. With an increase in the elastic modulus of the lining, the difference in the peak values of the bending moment and shear force increases, whereas the transverse displacement response is slightly diminished. With an increase in the elastic modulus ratio of hard rock to soft rock, the difference in the peak values of the bending moment, shear force, and transverse displacement of the tunnel, varied more along the tunnel axis. With the increase in the axial force, the seismic responses from the bending moment and shear force on the tunnel cross-section were significantly weakened.