Skip to content

Add an automatic check that URL redirects work #1089

Closed
@StevenMaude

Description

@StevenMaude
Contributor

In #1064, I found that some redirects I added weren't working as expected. I'm still not sure why that is yet.

Depending on the reason for it (are we encountering a limit? or is it something more subtle?) we might want to add a scheduled check that:

  • at minimum, the URL being redirected gives the redirect code specified
  • and, maybe even that the URL being redirected gets redirected to the correct destination

Activity

changed the title [-]Add an automatic check that redirects work[/-] [+]Add an automatic check that URL redirects work[/+] on Jan 11, 2023
StevenMaude

StevenMaude commented on Jan 12, 2023

@StevenMaude
ContributorAuthor

As a semi-automated process:

test $(cut -f1 -d' ' _redirects | awk '{print "https://3b9cf57d.opensafely-docs.pages.dev"$0}' | xargs -n1 curl -o /dev/null --silent --head --write-out '%{url_effective} '%{http_code}' \n' | grep "404" | wc -l) -eq 0

displays the URL and status code for each redirect, assuming a 404 catches every issue (which it possibly doesn't).

The better approach would be to compare the status code from the _redirects file with that from cURL.

added 2 commits that reference this issue on Jan 12, 2023
StevenMaude

StevenMaude commented on Jun 6, 2023

@StevenMaude
ContributorAuthor

This was completed in #1094.

See also #1207, where using a MkDocs plugin for redirects is proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @StevenMaude

        Issue actions

          Add an automatic check that URL redirects work · Issue #1089 · opensafely/documentation