How to bulk-import or export redirection rules?

Importing redirection rules is a productive way to add many redirection rules at once. redirection.io supports importing .csv files.

The import screen can be accessed from the "Rules" screen:

  1. redirection.io project dashboardhead to the dashboard of your project
  2. Rules menuhit the "Rules" menu link
  3. "Import rules" buttonClick the "Import" button, on the upper right corner of the page
  4. Select a CSV file containing the redirections that you want to setup. The import tool helps defining the role of each column, so the columns order is not important.
  5. "File format and columns" button in the "File format and columns", you can configure the CSV file format, ignore the first line, and choose for each column of the CSV file the type of data that it contains.
  6. the Markers step allows to define the properties of markers strings that have been included in the file. Each occurrence of a marker string will be replaced with a redirection.io marker
  7. At the "Execute import" step, you can choose to ignore errors in the imported file. If this switch is checked, the import tool will do its best to import all the rules it is possible and safe to create, and it will ignore errors or warnings. If the switch is not checked, the import will be more strict and completely fail even if there is only one error.
  8. Once started, the import duration depends on the number of rules to import - it usually takes some seconds, but can take several minutes if there are tens of thousands of rules. Should there be mistakes in the import file, the import tool will allow to download a CSV file containing the errored lines, so that you can fix them and try again to import the redirections file.

Format of the import file

The import tool of redirection.io is rather flexible and permissive. Here are some tips to know.

The columns order is not important

The only requirements on imported files is the file format, which must be a valid CSV file.

Once you have selected the file to import, the import tool displays the 100 first lines of the file. It allows to ignore the first line (if it is a header line) and define the role of each column. The column roles that can be mapped are: Source URL, Target URL, Status Code, Priority, Tags. These columns can appear in any order in the CSV file.

The three following columns are required:

  • Source URL*: This is the URL that will trigger a redirect response. It can be an URL starting with / or :// or http:// or https://
  • Target URL*: This is the URL the user will be redirected to. It can be an URL starting with / or :// or http:// or https://
  • Status Code*: This is the status code to use for the redirect. Make sure to choose a valid redirect status code

There can be two optional columns:

  • Priority: a numeric value to define the priority of the rule. Higher priority rules will take precedence over lower priority ones
  • Tags: comma-separated tags to be attached to the rule

The CSV file can include a header line, or not

The imported file can contain a header line, or not. During the import, you can tweak import options to bypass the first line. So, both of these files are valid to run an import:

Source URL;Target URL;Status Code
/some-source;/some-target;302
/this-is-not-found;;404
/this-is-gone;;410

and

/some-source;/some-target;302
/this-is-not-found;;404
/this-is-gone;;410

Imported files can define markers

Markers are a great feature of redirection.io to create rules that can be applied to many URLs at once.

In the third step of the rules import, you can define which strings have to be replaced with a marker. For example, you could import the following CSV file:

Source URL;Target URL;Status Code;Priority;Tags
/products/[CATEGORY_NAME];/shop/[CATEGORY_NAME];301;10;shop,category
/products/[CATEGORY_NAME]/[PRODUCT_ID]-[PRODUCT_NAME].html;/shop/[PRODUCT_ID]-[PRODUCT_NAME];301;10;shop,product
/products/[ANYTHING];/shop;302;1;shop

Specific strings have been used in the example CSV file:

  • [CATEGORY_NAME]
  • [PRODUCT_ID]
  • [PRODUCT_NAME]

These strings are placeholders that are intended during the import with redirection.io markers. This can be directly made at the 3rd step of the import form, or in the marker templates configuration if you think that these markers will frequently be used in your project:

The markers configuration during redirect imports

Once the import is executed, three rules will be created with the configured markers:

The three imported rules

Publish the rules, and they'll be applied to your website in seconds.

Imported files limits

The limit of the size of imported files is quite high, and mainly depends on the size of the URLs defined in the file. You should be able to import several hundred of thousands of rules with a single file. If it does not work, please split the import in several smaller files.

Imports can also define 404 and 410 actions

The import tool has been designed to help importing large redirection collections, but it can also be used to create rules with HTTP 404 - Not found or HTTP 410 - Gone actions. You just need to add a "Status code" column in the CSV file:

Source URL;Target URL;Status Code
/some-source;/some-target;302
/this-is-not-found;;404
/this-is-gone;;410

Importing very large rulesets

The import tool has been designed to import very large redirection files. The number of rules that can be created with one single import depend on the size of each URL, but you can expect to be able to load ~500k redirection rules with one single import, and it should take about 10 minutes to complete.

When importing large redirection files, we advise to check the switch "Ignore import errors". If there are some errors in the file, you will be able to download a CSV file at the end of the import, containing only the lines with errors. Once fixed, you may re-import this file to have your redirection plan completed in the shortest possible time.

Logs and rules exports

redirection.io allows to export logs or rules as CSV files. In the list of logs or in the list of rules, choose the columns to display, use the filters of your choice, and hit the "Export" icon, on the top right of the list. It will trigger the download of a CSV file containing the chosen columns, using the right filters.

"Rules export" button

This page has been updated on July 1st, 2024.
Can't find your answer?