You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In middleware redirect function you have: return NextResponse.redirect(urlObj.toString());
It produces 307 code which is "temporarily" redirect. This is not good for seo purposes, because google crawler will follow this redirect each time and each redirect chain decrease number of requests per day allowed for a site.
Solution is: return NextResponse.redirect(urlObj.toString(), { status: 308 });
This way google won't remember and follow redirect for default locale each time.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
I guess it's up to debate if the use case of redirecting /en to / for defaultLocale: 'en' and localePrefix: 'as-necessary' could be permanent.
Note that in the upcoming 3.0 release we're switching the default for localePrefix to always (as-necessary remains supported though). Among other topics, the question about the status code of this redirect also vanishes with localePrefix: 'always'. I'd generally recommend moving to that routing strategy.
However, let's go back to the topic:
because google crawler will follow this redirect each time
Where does the Google Crawler pick up the /en route in the first place? It's mostly there for compatibility, but / is the target of the redirect and the Link header also describes this route to be used for users that prefer the en locale:
Description
For seo-correctness when we want to skip default language we should do a redirect to page without mentioned page language:
next-intl/packages/next-intl/src/middleware/middleware.tsx
Line 106 in b5884a7
In middleware redirect function you have:
return NextResponse.redirect(urlObj.toString());
It produces 307 code which is "temporarily" redirect. This is not good for seo purposes, because google crawler will follow this redirect each time and each redirect chain decrease number of requests per day allowed for a site.
Solution is:
return NextResponse.redirect(urlObj.toString(), { status: 308 });
This way google won't remember and follow redirect for default locale each time.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://next-intl-example-next-13.vercel.app/en
Reproduction description
https://next-intl-example-next-13.vercel.app/en
Expected behaviour
https://next-intl-example-next-13.vercel.app/en this page should redirect to https://next-intl-example-next-13.vercel.app/ with 308 status code, not 307
The text was updated successfully, but these errors were encountered: