From Salzburg - motorway exit (A1) Thalgau (21km) and from Vienna - motorway exit (A1) Mondsee (15km) to St. Gilgen.
By train from Vienna or Germany:
From Vienna to Salzburg, from there take the bus or taxi via Hof and Fuschl to St Gilgen. From Germany via Munich to Salzburg, from there take the bus or taxi to St. Gilgen. (Salzburg train station to St. Gilgen - 28 km)
Salzburg Airport - then continue your journey to the main train station Salzburg and from there with the local bus to St. Gilgen.