An answer relevant to UK residents: use your UK-issued credit card.
If you purchase an airline ticket with a credit card issued by a UK bank, the bank is liable to you for any breach of contract by the airline (including if it goes into bankruptcy). This follows from Section 75 of the Consumer Credit Act, 1974.
To emphasize, because of some confusion in the comments below, it has to be a credit card, one where the card issuer lends you the money on credit for the transaction, and you pay the issuer back later at your leisure. An ordinary bank card or debit card, or indeed a charge card, does not come with this protection.
This law also applies to transactions made outside of the UK, including with foreign companies, if using a UK credit card. (As conclusively decided in the case of The Office of Fair Trading v. Lloyds TSB Bank).
The law gives greater protection than just a refund. The bank is liable to you for damages caused by the airline's breach of contract: if you have to buy an expensive new ticket to get home, the bank is liable for that extra cost as well. (This cost has to be "reasonable".)
The Financial Ombudsman gives some examples, for instance:
The failure of the airline with which she had booked return flights meant that Mrs K was obliged to buy tickets from a different airline to get her family home from their holiday. It was clear from the evidence that she had paid a reasonable price for these tickets.
The card provider's liability to Mrs K under section 75 was not limited to passing on any refund it was able to obtain from the airline. The card provider was also liable to her for the additional costs she had reasonably incurred as a result of the airline's breach of contract.
The flights from the USA had cost Mrs K £1,980.60, so the card provider's refund still left her out of pocket by £631.35. We upheld the complaint and told the card provider to pay her this amount.
Or in the case of a ferry company that went bust:
We looked at copies of the paperwork Mr M had sent the card provider, in connection with his claim. These documents showed clearly that what Mr M had bought from the ferry company had been a voucher costing £220 - not ten individual crossings each costing £22.
So we did not see why the card provider had argued that section 75 did not apply. The ferry company had clearly been in breach of its contract with Mr M. And the evidence showed that Mr M had made every effort to minimise his loss by obtaining the best deals he could get when paying for the crossings that were no longer covered by his voucher.
We agreed with Mr M that the card provider was liable, under section 75, to make good his total loss of £294.31. We said the card provider should also pay him £100, to reflect the inconvenience he was caused by its failure to accept the clear legal position under section 75.
- The ticket must be worth more than £100 (and less than £30,000).
- This doesn't apply for charge cards, only credit cards. (A charge card is a card where you have to pay off the whole balance at the end of the month, every month. The main examples of charge cards are the American Express Gold and Platinum cards.)
- This doesn't apply to debit cards, ordinary bank cards or cash cards, only credit cards. You would have signed a consumer credit agreement with a bank to have a credit card.