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.
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
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.
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
For example,
/mens?cgid=hats&color=red
is processed before
/mens?cgid=hats
/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 |