Fix logic to only run when we capture a lang & version slug
@@ -183,6 +183,7 @@ class ServeError404Base(ServeRedirectMixin, View):
# Always add a `/` to the filename to match our old logic:
# https://github.com/readthedocs/readthedocs.org/blob/4b09c7a0ab45cd894c3373f7f07bad7161e4b223/readthedocs/redirects/utils.py#L60
+ if lang_slug and version_slug:
filename = '/' + filename
# Check and perform redirects on 404 handler
