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
No related tags found
No related merge requests found
Pipeline #1128 passed
...@@ -267,9 +267,9 @@ INSTALLED_APPS = [ ...@@ -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 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 = [ ...@@ -279,6 +279,8 @@ MIDDLEWARE = [
] ]
``` ```
Notice tht it'll redirect only HTTP 200 Code.
## License ## License
Licence MIT Licence MIT
...@@ -12,4 +12,4 @@ class AllowOnlySiteUrl: ...@@ -12,4 +12,4 @@ class AllowOnlySiteUrl:
if(is_safe_url(request.get_raw_uri(), allowed_hosts=settings.SITE_URL) or response.status_code != 200): if(is_safe_url(request.get_raw_uri(), allowed_hosts=settings.SITE_URL) or response.status_code != 200):
return response return response
else: 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