This study investigates an on-demand first-and-last-mile ridesharing service (FLRS) problem considering the time-dependent travel time for an operator who manage a heterogeneous vehicle fleet. The operator, aiming to minimize the total operational cost, needs to simultaneously serve both first-mile (FM) and last-mile (LM) trips around a public transportation hub, such as a metro station. To holistically address this problem, we formulate a time-discretized mixed integer linear programming (MILP) model by constructing a time-expanded network and then extend a route-based set partitioning model. To yield good-quality solutions in a short computational time, a rolling-horizon-based column generation (RHCG) method is developed to handle real-time requests. An exact branch-and-price (BP) algorithm and a customized adaptive large neighborhood search (ALNS) algorithm are utilized to assess the solution quality of the applied RHCG. We conduct extensive numerical experiments created from real-world instances in Singapore to demonstrate the effectiveness of the proposed research methodology. The results of large-scale cases indicate that the RHCG outperforms both the commercial solver and the BP, and significantly reduces computational time in comparison with the ALNS. The implemented FLRS solution can decrease system-wide costs by 21.38% and increase shared-ride efficiency by 1.47 times, compared with the FM and LM services that operate separately.