This requires a Direct Airside Transit visa, unless you are a citizen of one of the exempt countries or have a visa/residence permit from certain countries (US, Canada, Australia, New Zealand, Ireland, Schengen). Applying for this visa involves going to the local visa processing centre, so it is not an online or on-arrival process, and takes around 3 weeks.
A US citizen flying New York to London to Egypt does not need to pay £20 for an ETA "visa waiver" to transfer in London. A UK citizen flying London to New York to Lima does need to pay for an ESTA