Automatically redirect new broken paths with rules. Every new broken path that is detected in your shop will be scanned by your rules. If a match is detected a redirect will automatically be created.
Quick overview
Don't have time to read it all. Here is the overview.
| Path to match | Redirect to |
|
Pattern: /category/coffee/{{wildcard_1}} Broken path: /category/coffee/high-mountain-blend |
Pattern: /products/{{wildcard_1}} Redirects to: /products/coffee/high-mountain-blend |
|
Pattern: /shop/coffee/{{wildcard_1}}/{{wildcard_2}} Broken path: /shop/coffee/blends/high-mountain-blend |
Pattern: /collections/coffee-{{wildcard_1}}/products/{{wildcard_2}} Redirects to: /collections/coffee-blends/products/expensive-brand-high-heels |
Creating a rule
Path to match
You must first define what paths you would like your rule to match. In most cases your path to match pattern will consist of absolute terms and wildcards. To explain it is easiest if we look at an example path:
/category/coffee/{{wildcard_1}}
Absolute terms
An absolute term is a static word in your pattern. For instance in the above pattern the words category and coffee are absolute terms. This means the rule you are creating will only match if the broken path being scanned has the words category and coffee in the same location as this pattern.
Wildcards
Wildcards are placeholders that will allow the path being scanned to have any value in the same position of the wildcard. Using the pattern above, the path being scanned could have any value in the position where {{wildcard_1}} is. So providing the path being scanned has the same absolute terms it will match regardless of what term is at the same position as {{wildcard_1}}.
Let's put it together using some examples to demonstrate (using the pattern above):
- /category/coffee/high-mountain-blend - MATCH - This path will match our rule. It contains the same absolute terms category and coffee in the same locations as our pattern and the product name high-mountain-blend is in the same location as our wildcard so it can be any value.
- /category/coffee-blends/high-mountain-blend - NO MATCH- This path will not match our rule. It contains the same absolute term category but the second term coffee-blends does not match the term in our pattern of coffee
- /category/coffee/blends/high-mountain-blend - NO MATCH - This path will not match our rule. While it contains the absolute terms and the term blends is in the same location as a wildcard the path is made of four sections but our pattern only has three.
A wildcard can easily be inserted into a path by typing an asertrix (*) or by pressing the wildcard button at the end of the field
. (see more on wildcards below)
NB: our rules enforce the scanned path being the same number of segments as the path to match pattern. This prevents loose matching. In most cases the need to match different length paths can be resolved by creating additional rules. Reach out if you need more help.
Redirect to
If a broken path being scanned matches our "path to match pattern" the rule it matches will create a redirect based on the pattern we define here.
Redirect patterns can consist solely absolute terms or a mixture of absolute terms and wildcard values. When a pattern is matched any values at the location of a wildcard will passed to the redirect pattern as variables. They are inserted into your redirect pattern by typing them exactly the same as in your match pattern.
Let's look at an examples.
Using the pattern from above /category/coffee/{{wildcard_1}} we might like to redirect matched paths to the relevant coffee product in our new Shopify store. To do this we would create the following pattern
/products/{{wildcard_1}}
Now when the broken path /category/coffee/high-mountain-blend is detected (which we already know matches) a redirect would be created to /products/high-mountain-blend. Here we can see that the value which was at the same location as the wildcard {{wildcard_1}} was high-mountain-blend and it is inserted into the redirect that is created.
Notify
If you are on a plan that includes customer notifications you can set whether a customer notification will be sent when your rules creates a redirect. This is very powerful as you can notify a customer you have found the page they were looking for within seconds of them landing on your 404 page.
The only time we recommend disabling notifications is when you create redirects to generic paths. i.e. if your rule just redirects to the home page. This can be confusing to your customer and does not add a lot of value and does not help them find what they were looking for.
Test
The best way to know how your rule will run is to test it. Once you have entered your path to match and redirect pattern enter a sample path into the tester and it will show you if it matches and what redirect path it would create if it does. Try it out using examples on this page.
Understanding wildcards
Our wildcards are very versatile and allow for a range of pattern matching and redirect creation unlike any other.
Structure
A wild card is made up of two parts
- {{}} - wildcard declaration. Double curly brackets defines a section of your test path as a wildcard. In fact brackets by themselves is enough to declare a wildcard
- wildcard_1 - variable name. This is a name given to the variable used to reference the value the wildcard matches. You can give your variable any name providing it only contains any of these a-z, 0-9 _ - values. If you use the build-in functions to add wildcards they will just increment wildcard_1 wildcard_2 etc. However you can rename them to something that represents your path segment providing you use the same variable name in the path to match and redirect pattern. i.e. {{category}}, {{product}}, {{section}}, {{silly_random_name}} are all valid wildcards.
Using wildcards
Whole segments
The most common way you will use a wildcard is to match an entire segment. i.e. /category/coffee/{{wildcard_1}}. In this pattern any term in the third segment will match this path.
Likewise when inserting a wildcard into a redirect pattern. Where only the wildcard is placed into a segment the value of that segment will be come the value passed from the matched pattern.
Partial segments
This is were things get powerful. Or wildcard matching allows for partial matching of a segment and concatenating absolute terms with wildcards.
Let's look at an example. Say we expect links that look something like this /shop/category_coffee/high-mountain-blend. To detect and redirect this we would create:
Path to match: /shop/category_{{wildcard_1}}/{{wildcard_2}}
Redirect to: /collections/{{wildcard_1}}/products/{{wildcard_2}}
Would create: /collections/coffee/products/high-mountain-blend
Likewise it can be used to concatenate. Let's try a path that uses subcategories. /shop/category/coffee/sub/blends/high-mountain-blend
Path to match: /shop/category/{{wildcard_1}}/sub/{{wildcard_2}}/{{wildcard_3}}
Redirect to: /collections/{{wildcard_1}}-{{wildcard_2}}/products/{{wildcard_3}}
Would create: /collections/coffee-blends/products/high-mountain-blend
To make this easier to read we could also rename our wildcard variables
Path to match: /shop/category/{{category_name}}/sub/{{sub_name}}/{{product_name}}
Redirect to: /collections/{{category_name}}-{{sub_name}}/products/{{product_name}}
Limitations and gotchas.
- Avoid matching patterns with a high number of wildcards as it will lead to loose matching. i.e. /shop/{{wildcard_1}}/{{wildcard_2}}/{{wildcard_3}} would match any four segment path that begins with /shop. Be very careful using vague matching like this as you may end up redirecting paths you do not intend. Where possible include static terms.
- Only one wildcard per segment. We currently do not allow multiple wildcards within a single segment. It can lead to loose matching and there are not many cases in which it is required.
Priority
Rules are evaluated on a first match basis starting from the first rule in your list through to the last. You can reorder the rules and combine priority to create even more powerful rules. You may pass through more specific rules before then matching more generic ones. Contact us if you have questions about how priority works.