Commit e6bb7b4f authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

fix: permenent redirect

parent 011d280a
Pipeline #6125 passed with stage
in 1 minute and 23 seconds
......@@ -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
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment