Opened 9 years ago
Closed 9 years ago
#25266 closed New feature (wontfix)
Allow regex for contrib.redirects
Reported by: | Berker Peksag | Owned by: | nobody |
---|---|---|---|
Component: | contrib.redirects | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Berker Peksag | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be really helpful if contrib.redirects would also accept a regex pattern as input.
For example, in some cases we want to redirect http://www.python.org/doc/X.Y.X/whatsnew/*
to http://www.python.org/release/X.Y.X/whatsnew/*
.
I can work on a patch if this seems reasonable.
Change History (3)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
I had the same initial reaction to this ticket as Tim.
In addition, this would change the interpretation of URLs containing a .
, a +
, or any other character that has a special meaning in regex. I don't have a good idea to preserve backwards compatibility there.
There's also the question of how we would implement this efficiently. Not all supported databases can anwser "give me the list of rows where field old_path
is a regex matching this value.
I think a custom middleware (if you have many patterns) — perhaps a modified version of RedirectFallbackMiddleware
— or a RedirectView
(if you have a handful of patterns) is the way to go.
comment:3 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I think writing regular expressions is better left to developers, in which I think using
RedirectView
or web server redirects should be sufficient. Feel free to write to the mailing list to get some other opinions.