@@ -145,7 +145,7 @@ def server_error_404_subdomain(request, template_name='404.html'):
145
145
the Docs default page (Maze Found) is rendered by Django and served.
146
146
"""
147
147
148
- def resolve_404_path (project , version_slug = None , language = None ):
148
+ def resolve_404_path (project , version_slug = None , language = None , filename = '404.html' ):
149
149
"""
150
150
Helper to resolve the path of ``404.html`` for project.
151
151
@@ -159,7 +159,7 @@ def resolve_404_path(project, version_slug=None, language=None):
159
159
project ,
160
160
version_slug = version_slug ,
161
161
language = language ,
162
- filename = '404.html' ,
162
+ filename = filename ,
163
163
subdomain = True , # subdomain will make it a "full" path without a URL prefix
164
164
)
165
165
@@ -197,16 +197,17 @@ def resolve_404_path(project, version_slug=None, language=None):
197
197
# Firstly, attempt to serve the 404 of the current version (version_slug)
198
198
# Secondly, try to serve the 404 page for the default version (project.get_default_version())
199
199
for slug in (version_slug , project .get_default_version ()):
200
- basepath , filename , fullpath = resolve_404_path (project , slug , language )
201
- if os .path .exists (fullpath ):
202
- log .debug (
203
- 'serving 404.html page current version: [project: %s] [version: %s]' ,
204
- project .slug ,
205
- slug ,
206
- )
207
- r = static_serve (request , filename , basepath )
208
- r .status_code = 404
209
- return r
200
+ for tryfile in ('404.html' , '404/index.html' ):
201
+ basepath , filename , fullpath = resolve_404_path (project , slug , language , tryfile )
202
+ if os .path .exists (fullpath ):
203
+ log .debug (
204
+ 'serving 404.html page current version: [project: %s] [version: %s]' ,
205
+ project .slug ,
206
+ slug ,
207
+ )
208
+ r = static_serve (request , filename , basepath )
209
+ r .status_code = 404
210
+ return r
210
211
211
212
# Finally, return the default 404 page generated by Read the Docs
212
213
r = render (request , template_name )
0 commit comments