This paper proposes a novel market-based system for ridesharing, where commuters are matched based on their declared travel constraints, the number of available seats (which could be zero), and their costs. Based on this information, the system then designates commuters to be either drivers or riders, finds appropriate matches, and calculates rewards for drivers and payments for riders. We show that, for this system, the well-known Vickrey-Clarke-Groves (VCG) mechanism is incentive compatible (IC), individually rational (IR) and efficient (i.e., minimizing cost), but results in a very high deficit, thus requiring large subsidies. We therefore investigate alternative mechanisms. We first consider mechanisms with fixed prices and show that no such mechanism can be both efficient and IC. Thus, we propose an inefficient IC mechanism but which has deficit control. We then consider a VCG mechanism with two-sided reserve prices. We show that this mechanism is IC and IR for a certain range of reserve prices, and we analyse the deficit bounds and how these can be controlled. We furthermore show that the deficit can be controlled even further by limiting the (costly) detours taken by the drivers when computing the allocations, thereby trading off efficiency and deficit.