RANDOM ENCOUNTERS
The game world consists of three zones: Safe, Unsafe, and Dangerous.
When the party stops to rest, I will ask one or more members of the party for a Survival check to find a safe spot to camp. Typically the DC is 12, but can be as low as 10 and as high as 20 depending on the area (like trying to find a campsite on the side of a mountain crawling with enemy soldiers.) If the check passes, the party has found a Safe Zone to camp in. If it fails, they have found an Unsafe Zone. And if it fails by 5 or more, they have found a Dangerous Zone. The players will then have the option to rest there, or move on and try to find a safer location.
Safe zones: In a safe zone, I will only check for random encounters during a Long Rest. The base chance for a random encounter is 0% but it might be adjusted depending on the party's actions (they're being followed, they were flashing around a lot of coin, etc.) If an encounter is indicated, roll or choose from Encounter Table 1. These encounters are usually traveling merchants, guards out on patrol, pickpockets in the crowd, and so forth.
Unsafe zones: In unsafe areas, I will check for random encounters for each Short or Long Rest. The base chance for a random encounter is 15% (a roll of 1-3 on 1d20), but can be adjusted by up to 10% in either direction based on the party's actions. If an encounter is indicated, roll or choose from Encounter Table 2. These encounters are usually wild animals, dangerous plants, and patrolling predators.
Dangerous zones: In dangerous areas, I will check for random encounters once for each Short or Long Rest, and the base chance for a random encounter is 30% (a roll of 1-6 on 1d20). If an encounter is indicated, roll or choose from Encounter Table 3. These are the local denizens of nearby dungeons, carefully-coordinated ambushes, and things that go bump in the night.
SHORT RESTS AND INTERRUPTIONS
Short Rests always take at least one hour. Upon finishing a Short Rest, you may spend your Hit Dice to recover hit points, and certain class features will refresh (warlocks recover their spell slots, for example).
If the Short Rest is interrupted by combat, spellcasting, or other strenuous activity, it is ruined. The party gains no benefit from the rest, and will need to spend another hour to attempt another.
LONG RESTS AND INTERRUPTIONS
When the party finishes a Long Rest, they recover abilities, spell slots, and hit points as noted in the Player's Handbook. A Long Rest always takes 8 hours, without exception. And you may only ever benefit from one Long Rest in any 24-hour period.
I am so very tired of arguing with my players about the elves' Trance ability, or anything Warforged-related.
However, if that rest was interrupted by combat, spellcasting, or other strenuous activity, the members of the party also gain one level of Exhaustion at the end of the Long Rest. This level of Exhaustion stacks with any other levels of Exhaustion you might have gained from sleeping in armor, being diseased, etc.
We had so many arguments about ruined Long Rests and what did/didn't constitute an "interruption" that I imposed this rule on the players. Now they still get the benefits of a long rest no matter what happens in the night; they just might wake up a little sore and cranky afterward. My players still hate it, but at least we've stopped arguing.