URL Redirect Processing and Examples

You can use the URL Redirect module to create redirects from existing Salesforce B2C Commerce URLs to new B2C Commerce URLs.

If you want to create URL redirects from a legacy platform, see URL Redirects to determine whether you want to use host aliases, static mappings, or mapping rules to create redirects.

URL Examples

The following are common uses of the redirect feature with examples of rules. All rules are assumed to be enabled. Each example shows the equivalent URL in both standard and search-friendly format. See also:
  • URL Rules URL Syntax: describes URLs optimized using the URL Rules module. Default for sites created after Release 13.1.
  • URL Syntax: describes standard B2C Commerce URLs, if no search optimization modules are enabled. This was the default for sites created before Release 13.1.
  • SEO Support URL Syntax: deprecated.

Example 1: redirecting category landing Pages

This example redirects a discontinued or renamed women's category page to a new ladies category page:

Redirect Rule for URL Rule Module URLs:

Incoming URL:
www.mystore.com/s/YourShop/womens

URI: /womens

Destination type: Category

Category Id: ladies

Redirect Rule for search-friendly URLs:

This redirect rule uses an asterisk for the locale, so that the rule isn't locale-specific. The asterisk symbol only indicates that the URI is locale-neutral. The asterisk symbol can't be used in any other portion of the URL as a wildcard.

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/womens/womens,default,sc.html

URI: /womens/womens,*,sc.html

Destination type: Category

Category Id: ladies

Redirect Rule for standard URLs:

This redirect rule doesn't include the locale and is therefore not locale-specific.

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/default/Search-Show?cgid=womens

URI: /Search-Show?cgid=womens

Destination type: Category

Category Id: ladies

Example 2: redirecting content Assets

This is most useful if you have microsites and want to redirect to a different content asset. For example, if you have a magic shop microsite and want to redirect to a holiday-themed microsite for magic.

Redirect Rule for URL Rule Module URLs:

Incoming URL:
wwww.mystore.com/s/YourShop/returns.html?q=returns

URI: /returns.html?q=returns

Destination type: Content

Content Id: returns

Redirect Rule for Search-Friendly URLs:

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/default/Page-Show?cid=returns

URI: /returns,*,pg.html

Destination type: Content

Content Id: returns

Redirect Rule for Standard URLs:

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/Information-About-Returns/returns,default,pg.htm

URI: /Page-Show?cid=returns

Destination type: Content

Content Id: returns

Example 3: Redirecting a Product from One Category to Another

This example redirects any products in a discontinued or renamed Women's category to the same product in a new Ladies category. We recommend using the import/export feature to create these redirects as it's currently necessary to create a separate redirect for each product.

Redirect Rule for URL Rule Module URLs:

Incoming URL:
www.mystore.com/s/YourShop/Quilted+Jacket/25518447.html?dwvar_25518447_color=JJ5FUXX#q=womens+jacket&start=1

URI: /Quilted+Jacket/25518447.html

Destination type: Product

Product Id: 25518447

Redirect Rule for SEO Support Module URLs:

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/Jacket/28436,default,pd.html?dwvar_28436_color=000128436360&start=3&cgid=womens-clothing

URI: /Jacket/28436,default,pd.html

Destination type: Product

Product Id: 28436

Redirect Rule for Standard URLs:

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/Product-Show?pid=28436

URI: /Product-Show?pid=28436

Destination type: Product

Product Id: 28436

Example 4: redirecting a locale-specific URL

This example redirects a URL with a specific locale. If you have locale-specific redirect rules, they take precedence over locale-neutral rules.

Redirect Rule for URL Rule module URLs:

URL Rules module URLs allow several ways of indicating the locale in the URL. The redirect you need to create depends on how you have configured locales in the module. See URL Rules Page Settings tab.

Incoming URL:
www.mystore.com/s/YourShop/Quilted+Jacket/25518447.html?dwvar_25518447_color=JJ5FUXX#q=womens+jacket&start=1

URI: /Quilted+Jacket/25518447.html

Destination type: Product

Product Id: 25518447

Redirect Rule for search-friendly URLs:

This redirect rule uses an * for the locale, so that the rule isn't locale-specific. The * symbol only indicates that the URI is locale-neutral and can't be used in any other portion of the URL as a wildcard.

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/womens/womens,en_UK,sc.html

URI: /womens/womens,en_UK,sc.html

Destination type: Category

Category Id: ladies

Redirect Rule for standard URLs:

This redirect rule doesn't include the locale and is therefore not locale-specific.

Incoming URL:
www.mystore.com/on/demandware.store/Sites-YourShop-Site/en_UK/Search-Show?cgid=womens

URI: /en_UK/Search-Show?cgid=womens

Destination type: Category

Category Id: ladies

Example 5: Using Wildcards

An asterisk character can be used as a wildcard in the URI field for standard and search-friendly URLs. Asterisks can be used in the URI portion of the URL, the query parameters, or both. For example:
/*-Show?cgid=mens
/default/Search-Show?*id=mens
/default/Search-Show?cgid=m*s
/default/Search-Show?*id=m*s
/*-Show?*id=m*s
/*ens,default,sc.html
/mens,*,sc.html
/mens,default,*.html
/*ens,*,sc.html
Note: You can add a position for each redirect that controls the order in which they are processed. You can do this in Business Manager on the URL Redirects page.

URL Redirects Locale Fallback Lookup

You can configure one URL redirect for different locales with the URI source type, as shown here:

Source URI '/Home-Show?brand=brandname' Destination URL '/home/brandname' 

To do this, request URLs are checked with and without the request locale to match the configured mappings, for example:

request 'www.my-host.com/[...]/default/Home-Show?brand=brandname' and 'www.my-host.com/[...]/en_US/Home-Show?brand=brandname' will be redirected to www.my-host.com/home/brandname.

In general, this lookup strategy applies to all URLs; and valid configured redirects result in a redirect loop for sites without locales in the URL path when the source URI was contained in the destination URL, as shown here:

Source URI '/home' Destination URL '/new/home'

An example request URL www.my-host.com/home shows the loop because it's redirected to www.my-host.com/new/home, for which the configured redirect will also apply because new represents the locale.

However, B2C Commerce does not process a locale fallback lookup for sites without locales in URL paths, for example, for sites with enabled storefront URLs and locale mapping set to none.

URL Redirect Processing

This section describes how B2C Commerce selects the redirect rule to use, based on an incoming URL. In this topic, URI refers to the portion of the URL after the domain name and before the query string. The URI portion of the URL is after Sites-YourShopHere-Site in the following examples.
                    www.mystore.com/on/demandware.store/Sites-YourShopHere-Site/en_US/Search-Show?_ie=iso-8859-1&cgid=womens
                    www.mystore.com/on/demandware.store/Sites-YourShopHere-Site/Sony-PSP-Game-Console/sony-psp-console,default,pd.html
                    ?cgid=electronics-gaming
  1. Does the redirect contain wildcards?
    • Yes - If the redirect contains wildcards, then it is processed after any redirects that don't contain wildcards. Redirects with wildcards are processed based on priority. See the last step for information on how wildcard URLs are processed.
    • No - Continue to the next step. URLs without wildcards are never assigned a priority.
  2. Is the URI of the incoming URL an exact match for the URI entered for any redirect rules?
    Note: The URI must match exactly to be considered. Partial matches are ignored.
    • Yes - If only one redirect rule matches, then that rule is used. If multiple rules have URIs that match exactly, then those rules are identified as candidates and processing continues.
    • No - No redirect is performed.
  3. What redirect rule has the most parameters that match the incoming URL?
    1. B2C Commerce sorts the candidate redirect rules by number of query string parameters and processes the rules with the largest number of parameters first.

      For example, /mens?cgid=hats&color=red is processed before /mens?cgid=hats

    2. B2C Commerce matches each parameter in the redirect rule to the parameters in the incoming URL. All parameters in the redirect rule must be present and have the same value in the incoming URL to be considered a match. It doesn't matter what order the parameters are listed in the redirect rule or incoming URL. Both search-friendly and standard B2C Commerce URLs are processed in the same way.
      Note: If the incoming URL has more parameters, these parameters are irrelevant to the redirect matching logic.
  4. For URLs containing wildcards: does the redirect have an assigned position?
    • Yes - Redirects are processed in order of priority, from low to high. The minimum value is one. Only integers are allowed.
    • No - Redirects with blanks for their priority are processed after any redirect with priority assigned. They are processed in an undefined order, so the processing doesn't match any rule. If you want to control the order in which the redirect is processed, add a priority.
Although B2C Commerce evaluates redirect rule candidates with the most parameters first, any incoming URL that does not have all of the parameters in the redirect rule isn't considered a match. In the example below, there are two the candidate redirect rules that match the URI of the incoming URL. The redirect rules are processed from most to least number of parameters. However, because the incoming URL does not have all of the parameters in the first redirect rule processed, it is not considered a match and the second rule /abc?a=1 is selected as the redirect.
candidate redirect rules incoming URL
/abc?a=1&b=2 www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1
/abc?a=1  

It doesn't matter if the incoming URL has more parameters. In the following example, all of the incoming URLs match the same candidate redirect rules, and all select the second rule /abc?a=1 as the redirect.

candidate redirect rules incoming URL
/abc?a=1&b=2 www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1 &c=1&d=1
/abc?a=1 www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1 &c=1
  www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1

Even though the redirect with a wildcard is more specific, it is processed after the redirect without a wildcard.

candidate redirect rules incoming URL
/abc?a=1&e=2 www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1&b=2&c=1&d=1&e=2
/abc?a=1&b=2&c=1&d=1&e=* www.mystore.com/on/demandware.store/Sites-MySite-Site /abc?a=1&b=2&c=1&d=1&e=3