Skip to content
Snippets Groups Projects
Verified Commit e6bb7b4f authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier
Browse files

fix: permenent redirect

parent 011d280a
No related branches found
Tags v0.6.25
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment