Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fay Arnold
djangoldp
Commits
e6bb7b4f
Verified
Commit
e6bb7b4f
authored
5 years ago
by
Jean-Baptiste Pasquier
Browse files
Options
Downloads
Patches
Plain Diff
fix: permenent redirect
parent
011d280a
No related branches found
Branches containing commit
Tags
v0.6.25
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+4
-2
4 additions, 2 deletions
README.md
djangoldp/middleware.py
+1
-1
1 addition, 1 deletion
djangoldp/middleware.py
with
5 additions
and
3 deletions
README.md
+
4
−
2
View file @
e6bb7b4f
...
...
@@ -267,9 +267,9 @@ INSTALLED_APPS = [
]
```
## 30
2
on domain mismatch
## 30
1
on domain mismatch
To enable 30
2
redirection on domain mismatch, add
`djangoldp.middleware.AllowOnlySiteUrl`
on
`MIDDLEWARE`
To enable 30
1
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
This diff is collapsed.
Click to expand it.
djangoldp/middleware.py
+
1
−
1
View file @
e6bb7b4f
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment