Skip to content

Custom urlconf breaks automatic redirects #7136

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
agjohnson opened this issue May 28, 2020 · 3 comments · Fixed by #10156
Closed

Custom urlconf breaks automatic redirects #7136

agjohnson opened this issue May 28, 2020 · 3 comments · Fixed by #10156
Labels
Accepted Accepted issue on our roadmap Bug A bug

Comments

@agjohnson
Copy link
Contributor

When using a custom urlconf, redirects like / -> /en/latest don't seem to work. Instead, a 404 error is returned. There is a similar issue where perhaps a top level request could redirect to en/latest with the prepended prefix -- ie: / to /subpath/foo/en/latest/, though this is less important likely.

To reproduce:

  • Give a project a custom urlconf: subpath/$language/$version/$filename
  • Browse to the project URL: foo.readthedocs.io/subpath/en/latest/ -- this works
  • Browse to the custom root: foo.readthedocs.io/subpath/ -- 404 here, where normall we'd redirect to foo.readthedocs.io/subpath/en/latest/
  • Browse to the top level path: foo.readthedocs.io/ -- also 404 here, though this might be harder to resolve
@agjohnson agjohnson added Bug A bug Accepted Accepted issue on our roadmap labels May 28, 2020
@ericholscher
Copy link
Member

ericholscher commented May 28, 2020

I think this is because we're defaulting some of the variables when there's a urlconf. We probably just need to tighten up that logic:

if any([
not version_slug and final_project.single_version,
not version_slug and project.urlconf
]):
version_slug = final_project.get_default_version()
if not lang_slug and project.urlconf:
lang_slug = final_project.language

Something like: if project.urlconf and '$version' not in project.urlconf

@stsewd
Copy link
Member

stsewd commented Mar 22, 2023

The new proxito implementation doesn't have this problem #10156.

@ericholscher
Copy link
Member

@stsewd awesome :)

stsewd added a commit that referenced this issue Jun 7, 2023
The implementation was changed to a more limited feature, path prefixes, they are simpler, and can be exposed to users, since they are plain strings.

Changes:

- Renamed some variables to match our new standard names
- The old implementation of this (urlconf) works together with the new implementation (current projects will continue to work).
- The resolver and unresolver have been adapted to support the new path prefixes
- `get_url_prefix` is meant to just get the prefix of the subproject, so it has been renamed to do just that.

Tests are passing on .com :)

There is also the question about what to do with the other views (the ones under`/_/`).
Opened #10181 to talk about that, that feature can be implemented in another PR.

And support for hiding the `language` component can also be implemented later #10307

Closes #7136
@github-project-automation github-project-automation bot moved this from Planned to Done in 📍Roadmap Jun 7, 2023
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
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants