Make sure folder links end in / in the gallery code.