fix(#36855/#30300): export 404.html correctly (#36910)
## Bug
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
The PR fixes #30300 and #36855.
The corresponding integration test case has been added.