Configure URL redirects

You can configure URL redirects for your site that specifically relate to 301 and 302 browser response codes, indicating that your redirected URL has either permanently or temporarily moved, respectively.

In the case of a 301 redirect, the URL is moved to a new target permanently. This type of redirection can help with moving the SEO authority from the old URL to the new equivalent. The following example illustrates a 301 redirect with an example site base URL: www.example-shop.com/example with the redirection rule:

  • originUrl: /smartphones/collection/id1234?show=all
  • targetUrl: /fr/smartphones/collection/id789?show=20
It is worth noting that 302 redirects are the preferred choice if you want to redirect a page for a limited amount of time.

URL redirects are created/deleted using the createRedirect and deleteRedirect endpoints in the Admin REST API. You can set a maximum number of redirects in order to avoid performance degradation by changing the property maxDbEntries in SeoRedirectionManager. Currently the total number of entries in the database defaults to 1 million.

URL redirection rules can be setup on a per site basis as each of the URL redirects are relative to the site base URL. If a siteId is not provided, then the rule acts as a global redirect for all sites. The following table describes the properties for redirecting URLs: Query parameters are not copied from the origin to target URL, instead you are required to include them in the definition of the redirect rule. When deleting a URL redirect, you specify the ID of the rule to delete using the path parameter of the deleteRedirect endpoint. For example: DELETE /ccadmin/v1/redirects/30001.

The following example illustrates a 301 redirect:

POST /ccadmin/v1/redirects HTTP/1.1 
Authorization: Bearer <access_token> 
Content-Type: application/json 
{ 
"originUrl": "/smartphones/collection/id1234?show=all", 
"siteId": "siteUS",
"type": 301,
"targetUrl": "/fr/smartphones/collection/id789?show=20"
}

See the Oracle CX Commerce REST API documentation in the Oracle Help Center for more information.