Skip to content

Exact redirects: allow use of $lang and $version #9240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielNoord opened this issue May 18, 2022 · 3 comments · Fixed by #10881
Closed

Exact redirects: allow use of $lang and $version #9240

DanielNoord opened this issue May 18, 2022 · 3 comments · Fixed by #10881
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required

Comments

@DanielNoord
Copy link

Details

Expected Result

We're a moving a folder in our documentation. Specifically the move is:
doc/messages/* to /doc/user_guide/messages/*.

After messing around with the redirects (a lot) we finally figured out how to set up a global exact redirect for all pages that fell under the messages directory (over 250+ pages, a page for each message pylint can emit).
One of the issues we ran into was that we couldn't use the $lang or $version variables. So, for the relevant PR (pylint-dev/pylint#6628) we had to do:

Type: Exact Redirect
From URL: /en/6628/messages/$rest
To URL: /en/6628/user_guide/messages/

This allowed us to test the PR, but then after the final merge we would need to add this as well:

Type: Exact Redirect
From URL: /en/latest/messages/$rest
To URL: /en/latest/user_guide/messages/

While this works for now, if we bump our version from 2.14 (current) to 2.15 the 2.14 documentation would break unless we add a redirect for /en/2.14/.
Similarly, all other languages won't benefit from this redirect as we only capture en.

Although I understand the concern that by using $version you would also redirect (for example) /en/2.5/ which doesn't have the directory moved, this shouldn't be an issue. Since the move hasn't taken place /en/2.5/messages/* shouldn't return any 404's and therefore no redirect will occur.

As far as I can see the only issue would be /en/2.5/messages/non-exisiting-page.html > /en/2.5/user_guide/messages/non-existing-page.html. But the effect of that would be the same: a 404. The change in url for that 404 is a risk/bug I would be willing to take.

Actual Result

Allow use of $lang and $version in Exact Redirects.

If the proposal is accepted and somebody could point me to the code that is currently handling these redirects I would be willing to take a look myself. I have no idea of how this is coded, but I feel like copying some of the expansion that happens for Page Redirects could be copied to Exact Redirects to fix this?

@humitos
Copy link
Member

humitos commented Jun 2, 2022

While this works for now, if we bump our version from 2.14 (current) to 2.15 the 2.14 documentation would break unless we add a redirect for /en/2.14/.

We've seen that Docs.rs handles this properly with these types of redirects: https://docs.rs/about/redirections

It may be a good idea to implement them in Read the Docs.

@stsewd
Copy link
Member

stsewd commented Jun 7, 2022

This could also be solved by adding the "$rest keyword" feature from exact redirects to page redirects.

@stsewd
Copy link
Member

stsewd commented Dec 7, 2023

This will be fixed with #10881. We decided to solve this use case by allowing wildcards in page redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants