#23531: APPEND_SLASHES behavior shouldn't redirect with a 301
-------------------------------------+-------------------------------------
Reporter: mattrobenolt | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: master
Severity: Normal | Resolution:
Keywords: common, middleware, | Triage Stage:
redirect | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by EvilDMP:
Old description:
> Redirecting with a permanent redirect (HttpResponsePermanentRedirect) can
> lead to 404s and other unexpected behavior when things move around.
>
> For example:
>
> In settings.py, `APPEND_SLAHSES = True` (the default behavior)
>
> In urls.py `url(r'foo/$', ..._`
>
> A user visits `example.com/foo` and gets redirected to `example.com/foo/`
> as expected.
>
> Later, we decide that we don't like slashes in our urls, and change to
> `APPEND_SLASHES = False` and change our url route to `url(r'foo$', ...`
>
> A user visits `example.com/foo` again (which is now the correct url) and
> their browser redirects them to `example.com/foo/` which is now a 404.
>
> This behavior happens specifically because Django has told it that this
> redirect is 100% going to happen, so the browser caches it and doesn't
> ask the server again. In my opinion, it's a bad idea that Django makes
> this assumption because it has no insight into what future plans are and
> whatnot.
>
> This behavior has also existed since at least 2007, so I'm not sure how
> much effort needs to go into changing this moving forward for 1.8+.
New description:
Redirecting with a permanent redirect (HttpResponsePermanentRedirect) can
lead to 404s and other unexpected behavior when things move around.
For example:
In settings.py, `APPEND_SLASHES = True` (the default behavior)
In urls.py `url(r'foo/$', ..._`
A user visits `example.com/foo` and gets redirected to `example.com/foo/`
as expected.
Later, we decide that we don't like slashes in our urls, and change to
`APPEND_SLASHES = False` and change our url route to `url(r'foo$', ...`
A user visits `example.com/foo` again (which is now the correct url) and
their browser redirects them to `example.com/foo/` which is now a 404.
This behavior happens specifically because Django has told it that this
redirect is 100% going to happen, so the browser caches it and doesn't ask
the server again. In my opinion, it's a bad idea that Django makes this
assumption because it has no insight into what future plans are and
whatnot.
This behavior has also existed since at least 2007, so I'm not sure how
much effort needs to go into changing this moving forward for 1.8+.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/23531#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.8e69f2414fcdc818bfda7e3832b389bb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.