4

I avoid Google's complaints about duplicates by using a 301 redirect, according to numerous tips here and on the net. However, I'm curious as to why it's appropriate to use a 301 code rather than a 308 code. I found this note in MMDN regarding 308:

The request method and the body will not be altered, whereas 301 may incorrectly sometimes be changed to a GET method.

Is there a simple general justification for 301 vs. 308?

1
  • This is an interesting question - I'd not heard of a 308 redirect before. After reading up on this a bit I posit that 301's are better established/well known because it confirms to an older standard - ie RFC2616 did not have a reference to it, but RFC7231 (and RFC 9110) does. If you are not worried about passing parameters it doesn't make a difference.
    – davidgo
    Feb 5 at 4:19

1 Answer 1

2

As davidgo mentions in the comments, the main reasons are "established convention" and backward compatibility.

The 308 (Permanent Redirect) was introduced in RFC-7238 in 2014, while 301, 302 have been around since at least 1997 (and 307 was introduced in 1999).

The introduction for RFC-7238 states:

[T]he status codes 301 (Moved Permanently), 302 (Found), and 307 (Temporary Redirect), which can be classified as below:

Notes Permanent Temporary
Allows changing the request method from
POST to GET
301 302
Does not allow changing the request
POST to GET
- 307

As you can see, the key reason for introducing the 308 was to allow for clients to perform a permanent redirect while requiring the client to maintain the original method - i.e. in the case of a form submission (or API call), the calling client should:

  1. Reissue the request, unmodified, along with all data to the new URL defined in the location response header.
  2. Update any "bookmarks" to point to the new location going forward.

If you issue a 301 redirect, most clients will just perform a GET on the URL, even if the original request was a POST - whether this is the desired behaviour for your application is something for you to decide.

2
  • 1
    Does it mean that in my case (redirection of url "duplicates" claimed by Google) I could use 308 just as well, or even better??
    – mja
    Feb 9 at 14:04
  • 1
    In general, the duplicates crawled by Google will have been requested via a GET request, so those would be fine to handle with a 301. GoogleBot will happily respect a 308 correctly, as will all modern browsers - so if you want to simply issue those as 308 that will be fine. Feb 16 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.