When a web server receives a request, it may return a redirection response (with a 30X return code). We use redirects for a few purposes,
- to prevent link rot by forwarding old paths to new locations
- to redirect specific addresses to external domains
Redirecting at the web server rather than with DNS has some advantages,
- We have more control over the format of the redirect, for example we can use wildcards and substitution.
- Redirection will happen after TLS, so HTTPS can be used.
- Clients will receive HTTP codes indicating that they were redirected, and whether the redirect should be considered permanent.
- The redirects are described in plain text in the book repository, making them more visible and easier to contribute to.
Netlify redirects¶
Redirects for The Turing Way are defined in nelify.toml in the array of tables [[redirects]]
.
The TOML syntax means that a new [[redirects]]
item is added for each redirect we want to define.
The syntax for Netlify redirects is described in their documentation, where the available options are also explained.
Our redirects¶
www¶
We have a wildcard, permanent redirect for https://www.book.the-turing-way.org/*
which returns the preferred url, without www.
Old book domain¶
We have a wildcard, permanent redirect for the old book domain at https://the-turing-way.netlify.app/*
which returns the new url.
Start page¶
In our DNS configuration we have pointed the-turing-way.org
and www.the-turing-way.org
to the Netlify load balancer. We redirect these to the-turing-way.start.page
as a landing page for The Turing Way project as a whole.
Moved chapters¶
Most of the redirects are for chapters or pages which have moved internally. The full list of these isn’t described here but can be seen in nelify.toml.
Helpers¶
Our helper redirects allow us to have easy to remember and share URLs which we can point to community resources, which may move. We currently have the following helpers,
Helper URL | Directs to |
---|---|
git | Our git repositories |
news | Our newsletters archive |
slack | An invitation to our Slack workspace |