Redirect .../index.html links from Sphinx HTMLDir #2208
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We recently switched from a Sphinx HTMLDir-style layout to Sphinx HTML. The redirect we have in place handles links of the form http://clearwater.readthedocs.io/en/stable/Clearwater_SNMP_Statistics/, but not http://clearwater.readthedocs.io/en/stable/Clearwater_SNMP_Statistics/index.html (which used to work, and we have a lot of now-broken links in that format).
This PR makes the latter style of link redirect correctly. I was worried that it would affect links like http://clearwater.readthedocs.io/en/stable/index.html (redirecting to http://clearwater.readthedocs.io/en/stable.html), but I checked and get_redirect_response is only called from the 404 handler at https://github.com/rtfd/readthedocs.org/blob/a3e5cf3134c5db089d30451fdd89f77a2ad354a1/readthedocs/core/views/__init__.py#L123, so it won't spuriously redirect pages that otherwise work.