Opened 14 years ago

Closed 13 years ago

Last modified 7 years ago

#14153 closed Uncategorized (invalid)

Redirects fail if URL has appended query string

Reported by: Richard Barran Owned by: nobody
Component: Contrib apps Version: 1.2
Severity: Normal Keywords: redirect
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The redirect middleware obtains the path of the current request with path = request.get_full_path(), then tries to find a match in the Redirect table.
If there is an appended query string, it will include this when querying the Redirect table (and so fail to find a match).
Shouldn't we use path = request.path instead?

Change History (4)

comment:1 by Daniel F Moisset, 13 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

I think the problem should be considered more carefully. One possible use of the redirect app is to be used in a site migration, where you actually might want to redirect based in query string (for example if your old site used ugly URLs like index.php?doc_id=101

comment:2 by Daniel F Moisset, 13 years ago

Triage Stage: AcceptedDesign decision needed

comment:3 by Luke Plant, 13 years ago

Resolution: invalid
Status: newclosed

For the reason given by dmoisset, and for backwards compatibility for people relying on current behaviour, I'm going to close as INVALID. At the moment, if you want the query string to be ignored you'll have to roll your own. A setting is not good solution for this, since you might have a mixture of cases where you want the query string and where you don't. A fuller solution would almost certainly require changes to the model, and we don't have a migration framework to support that.

comment:4 by Dan Madere, 7 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

I ran into this and it does seem like a bug because:

  • The redirects middleware doesn't require case sensitivity when making a match. The argument that you might want to redirect differently based on query params could also be made for different case variations of a URL.
  • One would expect the redirects middleware to match URLs in a similar manner as requested URLs are matched to URL patterns in urls.py. The urls.py matching never includes query params when it's looking for a match, so I'd expect the redirect middleware to do the same.
Note: See TracTickets for help on using tickets.
Back to Top