Reputation: 397
I have the following routes set up:
/business //look for a business
/business/biz/:id //look at a specific business
What I did is that if someone goes to /business/biz
it redirects to /business
.
My question is what status code I should use for that?
I don't think it's 301
or 302
because it's not a permanent move, and it's also not temporary, it's just a page that doesn't exist with a consistent redirect to a specific page.
//get /business/biz page
router.get("/biz", (req, res) => {
res.redirect("/business");
});
I looked at different questions here on Stack Overflow but didn't find a case that matches mine.
Upvotes: 1
Views: 887
Reputation: 108
It is recommended to use the 301
code only as a response for GET
or HEAD
methods and to use the 308
Permanent Redirect for POST
methods instead.
Check the full article here
Upvotes: 0
Reputation: 2285
To redirect /business/biz
on /business
you should return a 308 Permanent Redirect
.
This is a quote from Wikipedia about status 308 :
The request and all future requests should be repeated using another URI. 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change. So, for example, submitting a form to a permanently redirected resource may continue smoothly
You should also check this answer explaining differences between 301
, 308
, 302
, 307
and is well written.
Upvotes: 2