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
- 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:
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.
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.
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:
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:
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:
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:
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:
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:
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.
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.
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.
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
/*-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
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
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
- 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.
- 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.
- What redirect rule has the most parameters that match the incoming
URL?
- 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
- 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.
- 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 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.
/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 |