20
Domain redirects
planned
Aaron Adams
When I configure multiple domains for one site, I should be able to select a primary domain. The other domains should redirect to the primary domain.
This is not possible today because
createRedirect
only works with paths, not domains.I believe redirecting secondary domains to the primary domain is a more common use case than serving the same site from multiple domains.
Activity
Newest
Oldest
J
Jerome Dahdah
Hey! We have multiple country-specific domains that redirect to localized subdirectories of the main website. So:
https://www.example.com/ → https://www.example.com/en/
https://www.example.com/* → https://www.example.com/en/*
https://www.example.de/ → https://www.example.com/de/
https://www.example.de/* → https://www.example.com/de/*
https://www.example.fr/ → https://www.example.com/fr/
https://www.example.fr/* → https://www.example.com/fr/*
etc. We also have a few vanity URLs that need to be redirected similarly.
This is super easy to do with Netlify (docs: https://docs.netlify.com/routing/redirects/redirect-options/#domain-level-redirects). Right now we are using the Netlify-specific
_redirects
file for those redirects, while we have moved everything else over to createRedirect
in gatsby-node.js for a more idiomatic Gatsby approach. This is the only technical restraint preventing us from making the switch from Netlify to Gatsby Cloud.Joel Smith
planned
Slight adjustment. We've added the ability to redirect the provided url (sitename.gatsbyjs.io) but not other custom domains. Very possible and we'll add it to the roadmap!
S
Shruti Chaturvedula
complete
We now support domain redirects
D
David
+1 This is desperately needed, for a project migrating from old server to Gatsby host. We rebuild the site using Gatsby, and the URL structure has changed. We need to redirect from a few sub-domains (alias) to the "apex" domain. For example, from "fr.example.com", "en.example.com", etc. to "example.com". As others mentioned, at the moment, only "www" redirect is added automatically when adding customer domain.
Aaron Adams
Hey, I found another site that could use this feature 😉

Gregory Hardy
should redirect the default gatsbyjs.io domain too
J
James Rotering
I was just dropping by to make the same request. Until gatsby supports this, I'm working around it by 1) using canonical meta tags, and 2) redirecting in the browser when users use the domains that should be getting automatically redirected.