CorefinityCorefinityDocs
Open the Control PanelControl Panel
Redirects · 4 of 5

Read redirects from a file

Reads rules from the text of an nginx, Apache or CSV file and answers them with the lines it skipped. Nothing is saved: add the rules to your table and save it.

POST/api/corestack/sites/{site}/redirects/import

Path parameters

siteintegerRequired

The id of a site row. A website's production site and each of its environments has its own id. Digits only. At least 1.

Body

contentstring or nullRequired

The text of the file, as UTF-8, up to 512 KiB. Only the first 2,000 lines are read.

formatstringRequired
nginxapachecsv
hostsarray of strings or null

Limit every rule read to these domains of the site.

Returns

200 The rules read from the file, and what happened to each line.

Fields of the 200 answer
duplicatesintegerRequired
formatstringRequired
importedintegerRequired
linesarray of objectsRequired
Fields of each item
lineintegerRequired
reasonstring or nullRequired
resultstringRequired

What happened to the line, such as added, replaces, skipped or rejected.

ruleobject

One redirect rule as the API answers it.

Fields
enabledbooleanRequired
fromstringRequired
hostsarray of strings or nullRequired

The domains the rule is limited to. Null for every domain.

idinteger or nullRequired

The rule's id. Null for a rule that is not saved yet, as in an import or a test of unsaved rules.

keep_querybooleanRequired
notestring or nullRequired
positionintegerRequired

The rule's place in the table, starting at 1. A rule whose path is the address asked for (an exact rule, or a prefix rule's own path) is taken first, whatever its position. Otherwise prefix and regex rules are tried in this order, and the first match wins. On a domain, the rules limited to it are taken this way before the rules for every domain.

shadowed_byinteger or nullRequired

The id of an earlier rule that always answers first, so this one never matches.

statusintegerRequired
301302
tostringRequired
typestringRequired
exactprefixregex
rulesarray of objectsRequired
Fields of each item
enabledbooleanRequired
fromstringRequired
hostsarray of strings or nullRequired

The domains the rule is limited to. Null for every domain.

idinteger or nullRequired

The rule's id. Null for a rule that is not saved yet, as in an import or a test of unsaved rules.

keep_querybooleanRequired
notestring or nullRequired
positionintegerRequired

The rule's place in the table, starting at 1. A rule whose path is the address asked for (an exact rule, or a prefix rule's own path) is taken first, whatever its position. Otherwise prefix and regex rules are tried in this order, and the first match wins. On a domain, the rules limited to it are taken this way before the rules for every domain.

shadowed_byinteger or nullRequired

The id of an earlier rule that always answers first, so this one never matches.

statusintegerRequired
301302
tostringRequired
typestringRequired
exactprefixregex
skippedintegerRequired
warningsarray of objectsRequired
Fields of each item
lineinteger
messagestring
textstring

If it is refused

StatusReasonWhat to do
401noneSend a valid token as Authorization: Bearer <token>.
403company_unavailableYour company is unavailable.
403scope_requiredUse a token with the scope named in scope.
403two_factor_requiredTurn on two-factor on your account, then send again.
404feature_offThis feature is not on for your organisation yet.
409deletedThe site, environment or copy has been deleted, or is being deleted. Nothing can be changed on it. Restore a deleted site first if it can still be restored.
409managed_elsewhereThis site is read-only here. Change it in the control panel that manages it.
409provisioningThe site is still being created. Try again in a few minutes.
422invalidFix the field named in field; errors says why.
429rate_limitedWait for the seconds in Retry-After.

Reasons are listed by name in Errors and refusals.

The same task elsewhere

curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/redirects/import \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Redirect 301 /about-us.html /about\nRedirect 302 /summer-offer /offers/autumn\n",
    "format": "apache"
  }'
{
  "duplicates": 0,
  "format": "apache",
  "imported": 1,
  "lines": [
    {
      "line": 2,
      "reason": "Not a redirect",
      "result": "skipped"
    },
    {
      "line": 4,
      "reason": null,
      "result": "added",
      "rule": {
        "enabled": true,
        "from": "/team.html",
        "hosts": null,
        "id": null,
        "keep_query": true,
        "note": null,
        "position": 1,
        "shadowed_by": null,
        "status": 301,
        "to": "/about/team",
        "type": "exact"
      }
    }
  ],
  "rules": [
    {
      "enabled": true,
      "from": "/team.html",
      "hosts": null,
      "id": null,
      "keep_query": true,
      "note": null,
      "position": 1,
      "shadowed_by": null,
      "status": 301,
      "to": "/about/team",
      "type": "exact"
    }
  ],
  "skipped": 1,
  "warnings": [
    {
      "line": 7,
      "message": "RewriteCond is not supported",
      "text": "RewriteCond %{HTTP_HOST} ^www\\.example\\.com$ [NC]"
    }
  ]
}
Try it
Held in this tab's memory only. Never stored or sent to us.

This sends a real POST request and changes your account.

Use a token with only the read scope. How to make one

Was this helpful?
Open in ClaudeOpen in ChatGPT