I want to redirect people who access /url-path-before/feature/hoge/ to /url-path-after/feature/hoge/.
Using URLs, you can do it like this:
url(r'^url-path-before/(?P<path>.*)', RedirectView.as_view(url="/url-path-after/%(path)s", permanent=False), name="after"),
This will enable the redirection.
If you set permanent=False, it will be a 302 redirect.
If you don't specify, permanent=True will be used, resulting in a 301 redirect.
Since 301 redirects can be cached by the browser and cause inconvenience, it might be a good idea to start with permanent=False for testing. If there are no issues with the behavior, you can remove it later.
Comments