Ask either guard, “Which door would the other guard advise me to take?” The truth-telling guard will honestly indicate the bad door, and the lying guard will falsely indicate the bad door. Either way, you’re safe in taking the opposite door.
A sequel, from John Finnemore’s Souvenir Programme: