How to Add Redirects

Summary:

This How-To article explains how to add and manage Marketpath CMS Redirects. 

By Matt Zentz

A redirect simply redirects a browser to another page of a site. They are typically used for:

  1. Friendly URL's. Creating custom URL's that are easy to remember. For example, //mydomain.com/summer might redirect users to //mydomain.com/2017-08_summer-deals. The longer URL is the actual page URL within the system because there might be an older 2016 page, a 2015 page, etc. By only updating the /summer redirect each year customers will always know that it goes to the proper page.

  2. Renaming pages. When you rename a page Marketpath CMS automatically creates a redirect for the old page URL to the new page URL. We do this to avoid dead links on your site but you can always delete the added redirect.

  3. Regular Expressions. It may be desirable to create a redirect based on a regular expression where many variations of a URL can be caught and sent elsewhere. For example, if you added //mydomain.com/\d{4}$ as your regex pattern then you would catch all URL's for "mydomain.com" that end with 4 numbers.

Field Reference

Use Regex
If checked, the redirect lookup will check the URL against the given regex pattern. If there's a match, the redirect will occur. See More About Regular Expressions below.
Origin
The URL you want directed elsewhere. This must be in the form:

//DOMAIN/PATH

Both the domain and path values are required. If Use Regex is checked then the path should contain a regular expression pattern.
Destination
Where you want the visitor to end up. This can be a custom URL, a page, a document, or an image.
Is Permanent
Checking this will instruct browsers to cache the redirect result and skip contacting the web server. We recommend that you test a redirect before you check Is Permanent. Once the redirect works as expected, then check Is Permanent and republish.
Notes
Used for keeping internal notes about redirects.

More About Regular Expressions

Regular expressions in Marketpath CMS utilize .Net Regular Expressions. The goal is to capture patterns of characters and redirect the user to an alternate page or a different website altogether. Regular expressions can be used for the domain or the path or both. The example Origin below will redirect all domains for a given site that have a path starting with "how-to".

//[^/]*/how-to/.*

This might be useful if you move all pages to a new URL structure.

Regex Groups

You can also take advantage of regular expression groups, capture the results, and use those results in your Destination. Let's take the example above and add groupings:

//([^/]*)/how-to/(.*)

This regex pattern captures two groups - the domain, "([^/]*)", and the path after /how-to/, "(.*)". We can setup our Destination to include the captured values from those two groups:

https://somecustomapp.com/dosomething?domain=$1&page=$2

$1 refers to the first captured group (the domain) and $2 refers to the second captured group (the path after /how-to/).