Short answer: Fix it when the problems are specific and the foundations are sound. Rebuild when the same areas keep breaking, the data model is wrong for the business, or nobody can safely change it. If you can't tell which, audit first: a review costs far less than a rebuild you didn't need.
Part of the guide to audit, secure and scale.
When a site or app starts to struggle, the instinct is to throw it out and start again. Sometimes that's right. Often it isn't, and a rebuild just recreates the same problems with newer code. Here's how to tell the difference.
Fix it when
The problems are specific and you can name them: a slow page, a broken form, a missing permission check. The data is structured in a way that still matches how the business works. Someone can change the code without being afraid of it. In this case, targeted fixes are faster, cheaper and less risky.
Rebuild it when
The same areas keep breaking no matter how often they're patched. The way data is stored no longer fits the business, for example it was built for one location and you now have five. Nobody can change it safely, so new features take weeks and break old ones. Or it's built on a platform you've outgrown and can't get out of.
Audit first when
You can't tell which of the above applies, people disagree about it, or the stakes are high: customer data, payments, or a launch date. An audit gives you an outside view of what's actually wrong, ranked by risk and cost, before you commit money either way.
The honest answer is often “both”
Many systems need a handful of urgent fixes now and a rebuild of one part later, not a full rewrite. A good audit separates the two, so you fix what's dangerous this month and plan the bigger work when it makes sense.