Skip to content

can't use /en/ or /zh/ as path prefix with single version #8399

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
trim21 opened this issue Aug 6, 2021 · 2 comments · Fixed by #10660
Closed

can't use /en/ or /zh/ as path prefix with single version #8399

trim21 opened this issue Aug 6, 2021 · 2 comments · Fixed by #10660
Labels
Accepted Accepted issue on our roadmap Bug A bug

Comments

@trim21
Copy link

trim21 commented Aug 6, 2021

Details

( I replace the en with _en in the latest build, but older build are broken)

Expected Result

URL like domain/en/introduction.html should works fine.

Actual Result

all URL like /en/introduction.html or /zh/introduction.html prefix get 404

but url /en/extra/index.md works fine.

@stsewd
Copy link
Member

stsewd commented Aug 9, 2021

Thanks for reporting, this is a current limitation from our code that serves the documentation, since we try to map the URL to the correct version/translation/subproject instead of using the project information to map that URL to a correct file. I put some comments on an alternative implementation for our serve code that could fix this kind of problems #8327

@stsewd stsewd added Accepted Accepted issue on our roadmap Bug A bug labels Aug 9, 2021
@stsewd
Copy link
Member

stsewd commented Mar 23, 2023

Our new implementation of the code that serves documentation doesn't have this problem, the new implementation is under a feature flag, but we won't be able to support this case till we make remove the old implementation, specifically this

re_path(
(
r'^(?:projects/(?P<subproject_slug>{project_slug})/)?'
r'(?P<lang_slug>{lang_slug})/'
r'(?P<version_slug>{version_slug})$'.format(**pattern_opts)
),
fast_404,
name='docs_detail_directory_indexing',
),

stsewd added a commit that referenced this issue Aug 28, 2023
Mostly removing old code, there is only one small custom addition

https://github.com/readthedocs/readthedocs.org/blob/6595bdac198b482e1279c0e3b1925198f6baa631/readthedocs/proxito/views/serve.py#L144-L146

Django doesn't capture the first slash, previously we were getting the path from request.path_info, that includes the slash! When a request is done to `/` the path is set to "" (empty), our code relies on that being `/`.

- Closes #10408
- Closes #8399

### How to deploy this change

- Deploy everything as usual, but don't run the `projects 0105` migration!!!
- After deploy is done, run the `projects 0105`  migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Bug A bug
Projects
None yet
2 participants