http://api.cratejoy.com/v1/page_redirects/

Page Redirect Definition

  • path (string): The path of the URL on your store to redirect from. This value should start with a slash, e.g.: /about/about-us.php.
    • Requests to the path route on your storefront will only be redirected when the route doesn't exist in your theme code (and would 404 without an enabled redirect).
  • target (string): The URL to send redirects to, e.g. https://old-domain.com/about_us.php
  • code (integer): Status code to use for the redirect, i.e. use 301 for permanents or 302 for temporary redirects.
  • enabled (boolean): Enable or disable the redirect.

📘

A page direct from a working URL will be ignored. They'll only apply on pages that would otherwise be a 404.

Basic Usage

A redirect with the following attributes will forward requests to https://potatostore.cratejoy.com/blog/about-us.html to https://google.com with status code 302.

  • path: /blog/about-us.html
  • target: https://google.com
  • enabled: True
  • code: 302

Advanced Usage

You can also specify generic redirects. Generic redirects are templates that map paths on your store to targets on another domain based on a pattern. Here's an example:

  • path: /blog/(.*).html
  • target: https://myotherdomain.com/blog/{0}.html

This will forward any request that matches the regex specified by path to the target template. The {0} in the target template will be replaced with the matching text. The templating pattern is extensible to arbitrary regex patterns.

  • path: /blog/(.+)/(.+).html
  • target: https://myotherdomain.com/{1}/blog/{0}.html

The above pattern allows you to rearrange elements selected by the path, when filling them into the target template. The first element in the path will replace {0} in the target, while the second element will replace the {1}.