Mass Importing URL Redirects

Both Drupal 7 and 8 can redirect requests for specific pages/urls to newly defined pages/urls using the Drupal redirect module [https://www.drupal.org/project/redirect], which Eastern Standard typically includes in all Drupal builds. Additionally, there is a supplemental "Path Redirect Import" module that can be used for one-time site migrations/relaunches [https://www.drupal.org/project/path_redirect_import].  This page provides documentation for preparing a redirect map for importing into your Drupal site, as well as instructions for site administrators to import the redirect rules.

NOTE:  

  1. Drupal's redirect module can only process individual 1-to-1 redirects; wildcards are not accepted in the URLs.
  2. Drupal cannot distinguish redirects from multiple subdomains/domains with the same relative path (for example:  Drupal won't be able to distinguish between a redirected "about" request from http://sample.com/about and a redirected "about" request from http://example.com/about.  Since both originating requests are for the same relative url "about".   
  3. Drupal's redirect engine does not parse out/recognize any query string parameters (the part of a url following a ? or #, such as https://www.google.com/#q=drupal+8+path+redirect  or http://www.bing.com/search?q=drupal+8+redirect+path&qs=n&form=QBLH&sp=-1...

PREPARING THE SPREADSHEET (to be done by content management team)

To mass import redirects, you'll need a spreadsheet, with the following columns from left to right:

  • old page node ID or unique identifier
  • old page-specific fully qualified url
  • new page node ID or unique identifier
  • new page-specific fully qualified url

Within each column, all URLs should be consistent (either all with or without the primary domain).  

Download an excel spreadsheet to use as a template here.


TO IMPORT THE REDIRECT DATA FROM THE SPREADSHEET (to be conducted by site builders/development team)

In order to mass import redirects, the Path Redirect Import module (https://www.drupal.org/project/path_redirect_import) must be installed (stable release available for Drupal 7, a beta release is available for Drupal 8) 

Taking the provided spreadsheet, you may need to hide some columns or extract/parse out the relative urls before being able to import the redirect mappings.

Create a .csv file with the URL you will be directing FROM in the left column and the URL you will be directing TO in the right column.  All URLs should be relative (excluding the SomeWebsite.com).

Below is a sample screenshot of the CSV formatted spreadsheet, ready for import.

 

Go to the site and hover Configuration > Search & Metadata > URL Redirects > Import

This will bring you to the page to import redirects from a .csv file

The Delimiter field should be set to ',' > Check 'No headers' if you do not have headers in your .csv file > Click on 'Choose file'

Navigate to your csv file and click 'Open'

Then click 'Import' at the bottom fo the page.

You should see a green box at the top of the page

Recently Updated in Additional Site Management Features