Configure 301 HTTP Redirects for Legacy URLs

301 Redirects are used for permanent URL redirection, sending users to a different URL than the one they originally typed into their browser or selected from search engine results. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.

It's SEO best practice to have a single preferred domain name that other URLs point to. For example, if a customer enters company.com directly into their browser, they can be taken to www.company.com via a permanent 301 redirect. The redirect is important because it helps ensure that you obtain an aggregated page rank and authority scores for all versions of your site URLs, thus boosting your organic search engine rankings.

To Configure 301 HTTP Redirects:

  1. Ensure that all Salesforce B2C Commerce-generated URLs in the storefront use a single hostname, such as www.company.com.

    This is achieved by setting the site's HTTP Hostname and HTTPS Hostname appropriately in the Hostname Alias File.

    Note: This must be done right at go-live; it can't be done earlier and shouldn't be done later.
  2. Redirect from company.com to www.company.com.
    • Create a custom pipeline to redirect URLs (one named, for example, RedirectURL-Domain or RedirectSiteURL).

      The SiteGenesis application includes a sample redirect pipeline named RedirectURL.

    • Specify a static mapping between the legacy URL and the custom pipeline. Select SEO > Static Mapping.

      The static mapping has the following format.

     <legacy URL> [i] p,[<protocol>], [<host>], <pipeline>, [<locale>], [<parameter name>, <parameter value>]*

    Note: After Release 2.6.4, you no longer needed to specify the hostname as a parameter to the pipeline. The pipeline can now read HTTP Hostname from the site configuration with fallback to the instance's hostname.
    • Ensure that the 301 redirect is in place by specifying that the attribute permanent is set to true within the ISML tag (isredirect) used in the redirect pipeline template.

    <isredirect location="${pdict.Location}" permanent="true">

    Note: In the SiteGenesis application, this code is included in the redirectpermanent template.
  3. Define your external search engine settings to support the redirect.

    For example, in Google Webmaster Tools, set the preferred domain to www.company.com.

    Ensure that Google sees you as the owner of both domains by following one of their ownership verification methods.