If you change the slug of a content asset, or the URL of a PathFactory experience, any previously shared links to that asset or experience will break.
To provide a seamless experience for your visitors, you can set up a redirect from the old URL to the new URL. Redirects work at both the asset level and experience level.
Redirect rules are a separate permission within User Management > User Roles > Administrative Controls. By default, access to redirects is disabled for all users. A PathFactory user with administrative privileges must create or edit a custom role and enable redirect permissions to access this feature.
To create a redirect, you’ll use a regular expression.
About regular expressions
A regular expression uses specific characters to search, match, and replace text patterns. You can think of a regular expression a bit like the “find and replace” function within word processing programs.
If you’re unfamiliar with regular expressions, we recommend you read about them first before setting up a redirect. The following resources are a good place to start:
The regular expression characters you’re most likely to use for simple redirects are ^ and $.
^ indicates the start of the path.
$ indicates the end of the path.
For example, if you’re changing a content slug called slug which appears at the end of the URL, your regular expression would be slug$.
However, be aware if you have a landing page with the same slug, it will also be redirected.
Plan your redirect
If this is your first time using regular expressions, we recommend you plan and test the redirect before going into PathFactory to set it up.
First, find the original URL you’re changing. Copy it into a word processing program. Now, identify which part of the URL is changing.
Redirects in PathFactory only match the URL path. The URL path is a specific part of a URL that comes after the domain and points to the resource. This means both the domain and query string are ignored. By using regular expressions, we’re pattern matching. PathFactory URLs can be in many formats and composed of many parts, but the only section that requires replacement is the content slug within the URL path.
Let’s look at the parts of a generic content track URL.
Example of a URL path
In this example, the URL path is /c/content_slug.
It’s important to know there’s a second common format for content track URLs. If your content track has a custom URL applied, its structure will be as follows:
Example of a URL path
In this example, the URL path is track_custom_url/content_slug.
Now that you’ve identified the path, it’s time to write out the regular expression. Remember that PathFactory only cares about the slug within the URL path. The domain and query string are ignored. Thus, the URL path is functioning as if it’s at the end of the URL.
For our first example, your regular expression to find the content slug would be:
You don’t have to include /c/ because that’s not changing.
For our second example, your regular expression to find the content slug would be:
Just as with the first example, you don’t need to include the track’s custom URL because that isn’t changing.
Now that you’ve written the regular expression to find what you want to replace, write out what you want to replace it with. This is the new content slug. Let’s say we want the new slug to be:
You can test your regular expression at Regex101.com. In the left sidebar, set the flavor to Python and the function to Substitution.
Using the information from the previous example, enter the following:
Regular expression: content_slug$
Test string: the URL
Once the information is entered, the sandbox looks like the following screenshot:
Content Slug example
As you can see, content-slug was replaced with newcontent.
Once you’re confident in your regular expression, you’re ready to set it up in PathFactory.
Create a redirect in PathFactory
We recommend planning out the regular expression before going into the platform to create it. If you haven’t already done so, see the previous section.
You have one final decision to make before setting up the redirect. You must decide whether it’s a permanent redirect or a temporary redirect. You can choose between two redirect status codes:
- 301, permanent
- 302, temporary
The code you choose is important for search engines and SEO. If you’re permanently redirecting, using code 301 transfers the SEO authority of the original page to the new page. You can read more about redirects and SEO at Moz.
Now that you’ve planned your redirect, it’s time to set it up!
- Sign into PathFactory.
- From your user name, select Organization Settings.
- In the on-page navigation, select Redirect Rules. This menu option may be nested under More.
Redirect Rules button
- Select Add Redirect Rule. The Add Redirect dialog appears. The top of the dialogue contains several examples of regular expressions.
- In Request Pattern, enter the regular expression that identifies the text that is being replaced.
- In Destination Pattern, enter the new text that will be substituted.
- Under Redirect Status Code, select the appropriate code:
- 301: use this option if the redirect is permanent
- 302: use this option if the redirect is not permanent
- Select Submit.
If you create a redirect that doesn’t work, you can simply delete it from the platform without harming your assets and experiences.
PathFactory experience URL formats
We’ve included the URL structures for PathFactory experiences for your reference. Remember that the domain (in the following examples, the domain is example.com) and query string (in the following examples, the query string is ?x=) are ignored and do not need to be included in your regular expression.
https://example.com//?x= https://example.com/// https://example.com//
https://example.com// https://example.com// https://example.com/l/
Will redirects work with a reverse proxy?
Yes. If you have a reverse proxy set up, the PathFactory redirect will still work. Because your reverse proxy is essentially a domain, you don’t have to worry about specifying your reverse proxy in the regular expression.