Skip to content

Redirects

Borghild Selle edited this page Feb 19, 2024 · 6 revisions

Same domain redirects

Redirects are handled through the Sanity CMS by creating a new redirect document. All redirects created are permanent redirects. To create a new redirect:

  1. Type in the old slug without the domain, starting with /, in the From field. Example: /this-is-an/example
  2. In the To field, select the Page that the redirect should link to

Redirects TO a different domain

Redirects to a different domain are handled in Sanity, under the Settings > External Redirects menu item.

Redirects FROM a different domain

Different domain redirects are handled in the DNS and in the code.

A dedicated team is responsible for doing so, and this can be requested by creating a new ticket in 'service now'.

If an external redirect should be redirected to a specific slug, the logic also needs to be added to the code at: https://github.com/equinor/energyvision/blob/main/web/common/helpers/redirects.ts

Automatic redirects

All slugs ending with .html are automatically permanently redirected to the same slug without the .html. Example: /this-is-another/example.html is automatically redirected to /this-is-another/example

All slugs starting with /news that do not exist in Sanity are redirected to (fallbacks to) /news/archive

All slugs that aRe NoT LoWeRCaSed (except slugs from archived news) are redirected to their lower cased version.

Slugs from assets before 2016 are redirected to /content/dam/archive-assets/${locale}${pathname} #1399

The file located at /content/dam/statoil/documents/supply-chain/statoil-deposit-enrollment-form.pdf redirects to /where-we-are/us-owner-relations #1468

Code implementation

Some of the redirect logic is implemented in the file middleware.ts. Rest is in the redirect.js file which is imported to next config