See redirects.json
to define or update redirects.
Example for redirects.json
{
"/jobs": { "to": "https://jobs.example.com/", "statusCode": 301 },
"/resources/the-follow-up-formula": { "to": "/resources/followup", "statusCode": 301 }
}
Each line is in the format of:
"REDIRECT_FROM_PATH": { "to": "REDIRECT_TO", "statusCode": HTTP_STATUS_CODE },
Rules:
redirects.json
must be valid JSON. No comments in file.- The last entry may not have a trailing comma!
- The REDIRECT_FROM_PATH key:
- SHOULD be a URL Path, starting with a leading slash (good:
/jobs
; bad:jobs
; bad:https://close.com/jobs
) - SHOULD NOT include trailing slash (good:
/jobs
; bad:/jobs/
) - SHOULD NOT include any querystring (good:
/jobs
; bad:/jobs/?utm_content
)
- SHOULD be a URL Path, starting with a leading slash (good:
- The value should be an object with:
- A
to
field, which:- Can be either a path (
/pricing/
or/resources/sales/
) or a full URL (https://close.com/jobs
) - Can optionally include a querystring (
/pricing/?source=old-pricing
)
- Can be either a path (
- A
statusCode
field which supports values of301
(permanent redirect) or302
or307
(temporary redirects)
- A
- If we ever need to pass along, or merge, the request querystring to the redirect URL, that will require some changes to how our redirect system works.
- Currently the redirects.json file is publicly accessible, so don't put anything sensitive/secret there.
Changes to redirects.json
get deployed automatically (by CircleCI) along with the rest of the site. This means you can simply add a new line to redirects.json, push to master, and within a few minutes (after Cloudfront cache invalidation is complete) the redirect should be live.
This works because of a Lambda@Edge function attached to our Cloudfront distribution.
Currently changes to the redirects function logic are deployed manually.