Being routed through Slovakia is really not a problem in any way. Otherwise you can take a train to Vienna and connect from there to Prague if there is some reason I can't think of for you to avoid Slovakia. Again, there is no problem in any way, with going through Austria.
I usually buy rail tickets at the train station. Many online services charge higher prices, sometimes much higher. The only exception I use for buying tickets online is where I can deal directly with the national railroad company (NOT RailEurope) and can print the ticket on my printer rather than having it mailed. The Swiss railroad is one that works like that which I have used recently and the price is the same as at the station.