Assume gritty rest rules. Or, to be more accurate, assume you can only rest at certain safe points.
Have limited numbers of short-rest shrines within the dungeon. Each such shrine is one-use; once used for a short-rest, you can't use it again.
Resting in the dungeon otherwise is impossible.
Block most kinds of extra dimensional travel within the dungeon. Have force magic decay in the environment, so you can't use the hut.
---
Why do I say this?
Because once you have done that, you can now make the dungeon more dangerous with less monsters. So the total XP earned is less, but the total fights required is more.
Fighting 2-3 encounters, taking a short rest, 2-3 encounters, short rest, 2-3 encounters and then long rest becomes far more standard. Beating those 2-3 encounters to reach a shrine becomes key; and some shrines are 4 encounters deep.
At less XP per encounter, more encounters and more content before you level.
And with gritty rests, it becomes 10 days per baseline adventuring day. So instead of 45 days from 1 to 20, it is 450 days from 1 to 20, more than a calendar year.
If we add in any kind of serious travel of downtime it stretches out further. Imagine if different parts of the dungeon can be a week's travel apart, and many areas are 2 weeks from a place to have a safe long rest (how mega is your mega dungeon?). Now an expedition enters the mega dungeon, travels 2 weeks (attempting to avoid fights; maybe gets in 1 or 2) to the goal adventuring zone, does 6-9 fights with 2 short rests (taking 3 days) to defeat that zone, travels 2 weeks back to the nearest place of safety, and then takes a week for a long rest.
That is 14+14+7+3 = 38 days for 1 "adventuring day". At that rate, it is almost 5 years to reach level 20.
While those long periods of rest/travel don't have to take up table time (you can have mechanics for it), they do take up calendar time. And they explain why a partly cleared area recovers and becomes dangerous again if the PCs retreat for a long rest; because it has been a month.
---
Have a higher-level danger economy going on.
Areas of a dungeon are impacted by the player's actions more than just "did they kill creatures here". Some areas will repopulate. Some with change in response to being attacked. Others will clear out even though the PCs never went there.
Most areas repopulate or otherwise become dangerous again after a long rest if you don't clear/finish the entire area. Other areas, the monsters move out if a significant attack happens and refortify somewhere else, taking their treasure with them.
---
Don't make the mega dungeon too crowded. There should be long travel times within it, and areas with multiple routes. Cave complexes, mushroom groves, etc; not just corridors.