Well, there are many variables to consider with rail transport. Railroads themselves are pretty resilient and have been shown to survive even though the rest of the city is totally annihilated (as was the case in WWII). Railroads are also easily repaired - they are, after all, simply planks of wood and steel bars laid on top of gravel. It's a lot more work to lay a new railroad than to repair an existing one, as the former involves a great deal of surveying work, cutting down trees, building bridges, and levelling the terrain with dynamite.
Rail hubs, on the other hand, are much more complex. Especially in the 19th century, rail ports needed to be built as close to shipping hubs and factories as possible as there are no trucks and not much in the way of cranes and shovels. Rail hubs also depend on big investors and shareholders who were entrenched in the city itself - bankers, industrialists, politicians, etc. For the vast majority of these investors, relocation would be unthinkable unless the relocation would take place within the city itself.
As mentioned before, it's much easier to rebuild than to relocate. In World War II, cities like Rotterdam, Warsaw, and a myriad of cities in Germany and the Soviet Union were essentially wiped from the face of the earth except for the streets and foundations. Nonetheless, these cities were all rebuilt.