diff --git a/README.md b/README.md index cbba9f6f7032cc146a5f0e2169d501276572ea29..264545b7ce9dd8133fe7e2b28636ccf2b3c14dbe 100644 --- a/README.md +++ b/README.md @@ -267,9 +267,9 @@ INSTALLED_APPS = [ ] ``` -## 302 on domain mismatch +## 301 on domain mismatch -To enable 302 redirection on domain mismatch, add `djangoldp.middleware.AllowOnlySiteUrl` on `MIDDLEWARE` +To enable 301 redirection on domain mismatch, add `djangoldp.middleware.AllowOnlySiteUrl` on `MIDDLEWARE` This ensure that your clients will use `SITE_URL` and avoid mismatch betwen url & the id of a resource/container @@ -279,6 +279,8 @@ MIDDLEWARE = [ ] ``` +Notice tht it'll redirect only HTTP 200 Code. + ## License Licence MIT diff --git a/djangoldp/middleware.py b/djangoldp/middleware.py index baef4e030525db3fd13dc1ce3410346357134441..014b7b247056d4c81a13e61c9b22b6fe645d6db2 100644 --- a/djangoldp/middleware.py +++ b/djangoldp/middleware.py @@ -12,4 +12,4 @@ class AllowOnlySiteUrl: if(is_safe_url(request.get_raw_uri(), allowed_hosts=settings.SITE_URL) or response.status_code != 200): return response else: - return redirect('{}{}'.format(settings.SITE_URL, request.path)) + return redirect('{}{}'.format(settings.SITE_URL, request.path), permanent=True)