Redirects - NCIOCPL/cgov-digital-platform GitHub Wiki

What types of redirects do we need?

  • Everything is a 301 redirect.
  • Promo URL is needed - Advanced Editors only have access to this

Order of Precedence for Archived Pages

  • If you DELETE a page from the CMS, no additional action is needed.
    • Follow the workflow to archive the page and then you can delete it.
  • You can ARCHIVE a page if the content may need to be resurrected or needs to be kept in the CMS for some specific reason or timeframe.
    • Archiving the page removes it from the live site but keeps it in the CMS. Servers can still access the page which interferes with redirects based on the order of precedence (currently its page on site, file on site, redirect map and then promo URL).
    • This means that if you archive a page, you need to
      1. change the URL first (add -old to the pretty URL),
      2. archive the page,
      3. then create the new redirect.

Adding a Redirect Directly in Drupal

  • Manually create redirect(s) in the system. This is best for adding a small number of redirects.
  • Once published, the redirect should work immediately (note there's an outstanding bug (#2745) for redirects not working because 404s are cached)
  1. If you are archiving a page (rather than deleting it from the CMS), you first need to change the URL before you archive the page and create the new redirect (see order of precedence note above)
  2. Under Configuration > Search and metadata > URL redirects > Add redirect
  3. 'Path'
    • Must be a node within the CMS
    • Enter the path of the URL starting after www.cancer.gov/ for English and after www.cancer.gov/espanol/ for Spanish (i.e., do not include espanol in the path here for Spanish redirects)
    • Do not include forward slash [ / ] when entering the path in this field
  4. 'To'
    • If a page within the CMS is moved to another section of the site, begin typing the Page Title in this field and select it from the dropdown
    • If the content has a translation, either the English or the Spanish title may appear, depending on if you have come into the CMS from an English or Spanish page (and see www-cms.cancer.gov/espanol/admin...). You can select whichever appears - the language dropdown is what will determine the redirect.
    • If you need to redirect to a page not on Cancer.gov (i.e., an external URL), enter the full URL in this field, starting with https://
  5. Keep as 301 permanent redirect
  6. Select the language for your redirect from the dropdown

Redirect Import Manager

  • Use this when you have many redirects, too many to manually enter one by one. These redirects do not begin working right away; they take a bit of time to redirect (one-a few hours)
  • Under Configuration > Search and metadata > URL redirects > CGov Redirect Manager
  • You will need to put all your redirects in a .csv file for this bulk upload. The file should be formatted as follows:
    • Two columns: From URL, To URL.
      • DO NOT include a header row.
    • From URLs should be relative
    • To URLs can be relative or absolute
  • Relative URLs: enter the path starting after www.cancer.gov. In the CSV file, include the forward slash [ / ]. Spanish URLs should include /espanol/
    • English: /foo,/bar (cancer.gov/foo will redirect to cancer.gov/bar)
    • Spanish: /espanol/foo,/espanol/bar (cancer.gov/espanol/foo will redirect to cancer.gov/espanol/bar)

Troubleshooting

There is a known issue (#3248) where redirects fail because a page still exists at the old URL, but in the "Archived" state. To work around this, edit the page, change its pretty-url field to end with -old, and move it back to the "Archived" state.

To find the page, go the URL which is failing to redirect and change the browser's address field to the CMS URL. (i.e. If www.cancer.gov/old-url is failing to redirect, go to that page and change the address field to www-cms.cancer.gov/old-url.) This will reveal the existing page.

Site Sections - for archived and deleted pages

  • If you archive a page(s), keep the related site section(s) so the page URL can still be viewed within the CMS
  • If you delete a page from the CMS,
    1. edit the site section, removing the page to be deleted as the site section landing page
    2. delete the page
    3. delete the site section

Other considerations

Site wide search

Removing a page from the site does NOT remove it from the site wide search. The search crawler will assume that a previously "known" page is only temporarily available and will make multiple attempts to retrieve it again. These attempts may take place over a span of weeks, in the meantime, the "last known" information about the page will be retained.

Removed pages should also be manually removed from site wide search.

Drupal redirect vs. Akamai

Redirects count as requests against the Drupal server. Pages with low traffic volumes (10s of visits per month) should be redirected in Drupal. Pages with high traffic volumes (1000s of visits per month) should be redirected in Akamai instead. The cutoff between the two is a judgement call.