In recent years, the capabilities of legged locomotion controllers have been significantly advanced enabling them to traverse basic types of uneven terrain without visual perception. However, safely and autonomously traversing longer distances over difficult uneven terrain requires appropriate motion planning using online collected environmental knowledge. In this paper, we present such a novel methodology for generic closed-loop preceding horizon footstep planning that enables legged robots equipped with capable locomotion controllers to autonomously traverse previously unknown terrain while continuously walking long distances. Hereby, our approach addresses the challenge of online terrain perception and soft real-time footstep planning. The proposed new formulation of the search-based planning problem makes no specific assumptions about the robot kinematics (e.g. number of legs) or the used locomotion control schemes. Therefore, it can be applied to a broad range of different types of legged robots. Unlike current methods, the proposed new framework can optionally consider the floating base as part of the state-space. It is possible to configure the complexity of the planner online, from efficiently solving tasks in flat terrain to using non-contiguous contacts in highly challenging terrain. Finally, the presented methodology is successfully applied and evaluated in virtual and real experiments on state of the art bipedal, quadrupedal, and a novel eight-legged robot.