Reputation: 492
I'm struggling with a nginx redirect that I've set up.
Basically, I want to redirect /case-study/ to /case-studies/ but don't want to redirect any url past /case-study/*.
I have this setup already:
location = /case-study/ {
rewrite ^(.*)$ /case-studies/ permanent;
}
Which works for /case-study/ but also redirects any url after /case-study/test-url-redirect
Cany anyone help me out on this one.
Upvotes: 0
Views: 127
Reputation: 6841
The simplest way is to make it a regex location like so:
location ~ /case-study(/?)$ {
return 301 /case-studies/;
}
Should match /case-study
and /case-study/
and redirect to /case-studies/
but not redirect anything that is under case-study
Upvotes: 1