Import 301 Redirects via CSV file

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000088694

When migrating a website to a new platform, URL structures often change. It is best practice to implement permanent (301) redirects from the previous URLs of important pages to their corresponding new destinations.


The platform supports bulk import of redirect rules using a CSV file.


Preparing the Import File


Create a CSV file containing each redirect to be applied. At minimum, this file must include two columns:


  • source_url — the original URL that requires redirection
  • destination_url — the target URL to which the original should redirect

The sample redirect CSV open in Google Sheets with the required source_url and destination_url columns highlighted.


The CSV may include additional optional columns intended for developer reference only (e.g., type, db_id). These are not required for successful import.


The sample redirect CSV open in Google Sheets with the optional type and db_id columns highlighted, both marked not required (developer use).


Examples of values used by the optional type column include:

"type"Field Description
adminManually created 301 redirects through the admin dashboard.
data_postSingle Image Post Type redirect
list_servicesSub/sub-sub category page redirect
list_professionsTop category page redirect
photo_groupMultiple Image Post Type redirect
profileMember Profile redirect


Important Note: For type "import" can also be specified to identify which redirects were imported and which ones were created by the system.


Please see the sample CSV file attached here.


Starting From an Export

The Export CSV button on the 301 Redirect Rules page downloads the redirects currently shown, with any search and filters applied, in the same columns the import reads. An export makes a convenient starting file: edit or add rows, then import it.

301 Redirect Rules page with the Import CSV button (1) and the download icon for exporting the shown redirects as CSV (2).

  1. Import CSV: opens the import dialog.
  2. Export CSV: downloads the redirects shown in the list as a CSV file.

Uploading the File

  1. Go to Developer Hub and click Manage Redirects on the 301 Redirect Rules card.
  2. Click Import CSV. The Import CSV File dialog opens.
  3. Drag the CSV file onto the dialog, or click browse and choose it. Files up to 10 MB and 50,000 rows are accepted.
  4. The dialog checks the file before anything is imported and shows its size and number of rows. Replace picks a different file and Remove clears it. If the headings are missing or the file cannot be used, the problem is shown here instead.
  5. Click Import CSV.

Import CSV File dialog with the column rules (1) and the drag and drop area with a browse link (2).

  1. The column rules: the first row holds the headings, source_url and destination_url are required, and type and db_id are optional.
  2. The drop area. Click browse to choose the file instead of dragging it.

Import CSV File dialog showing the chosen file with its size and row count (1) and the Import CSV button (2).

  1. The checked file, with its size and number of rows.
  2. Import CSV starts the import. It stays disabled until the file passes the check.

Reading the Import Report

When the import finishes, a report shows how many redirect rules were imported, and the list behind it refreshes. Rows that could not be imported are skipped, and the report gives the reason for each one, EG:

  • The source already has a redirect rule (or appears twice in the file).
  • source_url or destination_url is empty.
  • source_url is a full address instead of a path on the website, like old-page.
  • source_url and destination_url are the same.
  • The address holds characters a web address cannot contain, such as quotes or angle brackets.

Columns the import does not recognize are ignored, and the report lists them under Columns not imported.

No Redirect Rules Imported report listing skipped rows and their reasons (1) with a Download Skipped Rows button (2).

  1. The reasons rows were skipped, by row number in the file.
  2. Download Skipped Rows saves a CSV of just the skipped rows (row number, source_url, destination_url and the reason). Fix those rows and import the downloaded file again.

Imported rules with no type in the file are given the type import, which keeps them apart from redirects the system created.

Note.
The import runs as one batch: if a row cannot be saved partway through, no rows from that file are added, and the report asks for that row to be checked before the file is imported again.

To verify many redirects at once, an external HTTP status checker such as https://httpstatus.io/ can be used.