A bathroom exhaust fan should vent to the outdoors, either directly up through the roof of the home or through ducting to an outside wall. Venting into the attic releases humidity into the upper areas of the home, causing mildew and mold and eventually rotting the wood.
The most direct venting method involves installing a vertical duct from the exhaust fan and cutting through the roof. However, since this involves piercing the roof of the home, adequate sealing and insulation are essential to prevent leaks around the exhaust vent. It is possible to connect bathrooms near outside walls to vertical exhaust vents on the wall, but the complex ducting required makes this a difficult prospect for central bathrooms.