Redirects
Every website has the need for redirects. For example if you relocate or delete content, you want your users to still be able to find it or the next best thing. See the document Authoring and Publishing Content for more information on deleting content.
You can intuitively manage redirects as a spreadsheet called redirects
(or redirects.xlsx
) in the root of your project folder.
The spreadsheet has to contain at least two columns titled Source
and Destination
.
- The
Source
is relative to the domain of your website, so it only contains the relative path. - The
Destination
can be either a fully qualified URL if you are redirecting to a different website, or it can be a relative path if you are redirecting within your own website.
After making changes to your redirects spreadsheet, you can preview your changes via the sidekick and have your stakeholders check that the redirects are working on your .page
preview website before publishing the redirect changes to your production website. See the Sidekick documentation for more information about switching between environments.
Redirects take precedence over existing content, which means that if you have an existing page with a given URL, defining a redirect for that same URL will serve the redirect for that page and “hide” the existing page. Conversely if a redirect that has been set up on an existing page is removed, the existing page will be served again, unless the page was unpublished.
Remember that if your redirect workbook has multiple pages (worksheets), then the redirects will only work on the sheet that is called helix-default
. This allows you to manage more complex redirects through spreadsheet formulas. The spreadsheets and JSON documentation page has all the details.
Advanced Redirects with Wildcards in CDN
There are some cases where simple redirects are not enough, and you may need more advanced rules. For example, you might want to apply a redirect to all pages under a specific path, regardless of the exact URL. This is where using wildcards in your CDN can be helpful. Wildcards allow you to match multiple URLs under a common path, simplifying the redirection of entire sections of your site.
Example: If you want to redirect all URLs under /old-path/
to /new-path/
, including any subpages (e.g., /old-path/page1
, /old-path/page2
), you can configure a wildcard redirect in your CDN.
- Input URL pattern:
/old-path/*
- Redirect to:
/new-path/$1
The wildcard (*
) captures anything after /old-path/
, and $1
represents the captured part of the URL, ensuring the structure is maintained in the new location.
Note: The specifics of configuring these redirects depend on the CDN provider you are using. Different vendors may have their own syntax, interface, and capabilities for handling wildcards and advanced redirect rules. Always consult the documentation of your specific CDN for guidance on how to implement wildcard redirects.