Table of contents


Redirect a route

Sometimes, there is a need to manually redirect existing URLs to another internal location, usually due to content being archived or because the slug has been changed.

There is also a regular requirement for creating short URLs on behalf of departments, usually for use with for campaign materials.

Getting information on current redirects

To find if there is already a redirect for a particular path:

govukcli set-context production-aws
govukcli ssh router_backend


govuk_app_console router-api
> Route.where(incoming_path: '/path-to-item')

Redirect routes have the handler redirect.

Redirecting from the original publishing app

The preferred method of creating redirects is to use the publishing app that originally published the content to unpublish it and redirect it to another page using the Publishing API.

This ensures that the workflow and publishing history stays within the app wherever possible.

Using the Short URL Manager

If the redirect is from a URL that is not a currently-published content item, you should first look to use the Short URL Manager to create a redirect request. Requests are checked and approved by content designers, after which they are made live.

Redirects created in Short URL Manager are published via the Publishing API.

Specific Signon permissions are required to make and approve redirect requests through the Short URL Manager. Additionally, there is a advanced_options permission which enables creating redirects for pages that are already owned by other apps, creating prefix type redirects, and using non-default values for the segments_mode.

Fixing incorrect Corporate Information page redirects

There have been a few occasions where Corporate Information pages have started redirecting the English version to a translation. Should this happen, the redirects can be identified with:

> Route.where(incoming_path: /\/about/).each do |route|
>   puts "#{} #{route.incoming_path} -> #{route.redirect_to}" if route.handler == "redirect"
> end

That will list the id and paths for each redirect. Redirects from the English version to a translation, for example:

579a109cd068b406250014e4 /government/organisations/companies-house/about/access-and-opening -> /government/organisations/companies-house/about/

…can be deleted with

> Route.find('579a109cd068b406250014e4').destroy

For the deleted routes to take effect, you need to reload the router.

> RouterReloader.reload

Redirects from campaign sites

The campaigns platform is a WordPress site managed by dxw. Redirects from a * site require a support ticket. Currently, Mark McLeod or Kelvin Gan can raise a ticket.

This page was last reviewed on 25 February 2019. It needs to be reviewed again on 25 August 2019 by the page owner #govuk-2ndline .
This page was set to be reviewed before 25 August 2019 by the page owner #govuk-2ndline. This might mean the content is out of date.