For 1), if you don't want to do a separate route for every single route on your website, you'll need middleware that implements process_exception
and outputs an HttpResponseRedirect
.
For 2 and 3, those are rules that are presumably limited to specific routes, so you can do them without middleware.
2 might be doable in urls.py
with a RedirectView
, but since the relevant bit is a query string argument, I would probably make that an actual view function that looks at the query string. Putting a ?
character in a url regex seems strange because it will interfere with any other use of query strings on that endpoint, among other reasons.
For 3, that's a straightforward RedirectView
and you can do it entirely in urls.py
.