How to import redirects using Yoast SEO Premium

Yoast SEO Premium comes with the functionality to import redirects from other redirect plugins, from a CSV file, or from a .htaccess file. In this article, we’ll show you how to import redirects using Yoast SEO Premium.

How to import redirects using the Import and Export feature

Yoast SEO Premium includes the option to import your redirects from popular redirect plugins, from a .CSV file, or from an .htaccess file. You can find the redirect import feature by following the steps below.

  1. In your WordPress Dashboard, go to Yoast SEO


  2. Go to Tools


  3. Click on Import and Export

    Screenshot of the Tools settings in Yoast SEO, highlighting the Import and Export link

  4. Go to Import redirects


  5. Choose an import method

    Yoast SEO Premium allows you to import from supported redirect plugins, from a CSV file, or from a .htaccess file.

How to import from a supported redirect plugin

The first option is to import from the following plugins:

Please note that with Redirection, Yoast is expected to import Groups and any Regular Expressions (either as part of a group or not).

How to import from a CSV file

The second option is to import from a custom CSV file. This method requires that the syntax and format are correct.

  • First line must be: Origin,Target,Type,Format or "Origin","Target","Type","Format"
  • File must use a comma separator
  • File must contain only one redirect entry per line
  • File must use UTF-8 encoding
  • File must use Unix line endings
  • The target URL cell for 410 and 451 redirects must be empty
  • File must not contain a mixture of LTR and RTL characters

Download an example CSV file

Download an example .csv file here: Yoast SEO redirect example

Multisite

See our Frequently asked questions about importing from CSV file for a specific concern about multisites.

Plain redirects

Examples of plain redirect entries in the CSV redirect import file:

"/three-zero-one","/",301,"plain"
"/three-zero-two","/",302,"plain"
"/three-zero-seven","/",307,"plain"
"/four-ten","",410,"plain"
"/four-five-one","",451,"plain"

Regex redirects

If you are not sure what Regex redirects are, learn more about them in our What are Regex redirects article.

Examples of Regex redirect entries in the CSV redirect import file:

"^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$","/$4",301,"regex"
"^/([0-9]{2})/(?!page/)(.+)$","/$3",302,"regex"
"^/([0-9]{2})/(.+)$","/$2",307,"regex"
"^/([0-9]{4})/(?!page/)(.+)$","",410,"regex"
"^/([0-9]{3})/(?!page/)(.+)$","",451,"regex"

Frequently asked questions about importing from CSV File

Can I add plain and Regex redirects in the same file?

Yes. The CSV file can contain a mix of Regex and plain redirects.

Can I use the CSV import to change existing redirects?

No. Existing redirects are skipped during the import process. Please use the redirect manager to update existing redirects.

Is the CSV file case sensitive?

Yes. Especially the format column, which must be in lowercase.

Can I create or edit the CSV file in a spreadsheet program, like Excel or Google Docs?

Yes. Most spreadsheet programs can convert a spreadsheet into a CSV file. However, the converted CSV file must use the required syntax and formats listed above. We recommend using a plain text editor to review the converted CSV file to ensure the file matches the requirements above.

Why is my CSV file not importing?

The most common cause for the CSV import to fail is the format of the file. Please download a fresh copy of the example file above and run the import again. If the example file works and your custom file does not, please check the format of the file in a text editor. If the custom file continues to fail, please contact support.

Can I import a large CSV file?

Yes. The import can handle a large CSV file. However, having too large of a CSV file may result in server time-out issues. If you experience time-out issues try breaking the file into smaller chunks and importing each one, one at a time.

The other option is to increase your resources available in the PHP environment (max_execution_time) this will allow the import more time to complete. You may also want to increase the following PHP values to increase the resources available to the import function: upload_max_filesize, post_max_size, and memory_limit. If you are not sure what that means or how to do that, your host provider can help.

Do I have to use quotes in the file?

No. It’s common practice to quote cells that are empty or contain text. However, it’s not required and the import will work with a mixture of quoted and unquoted cells.

Can the origin URL contain the site URL?

Yes, but it’s not recommended. The origin URL is relative to the site where you are importing the redirects. The import process will attempt to make the origin URL relative to the WordPress site URL. However, this can fail if the WordPress site URL is not an exact match to the URL in the import file. Therefore, we recommend that Origin URLs start with a / and not the domain.

Can the target URL contain a full absolute URL?

Yes. However, we recommend only using full absolute URLs when linking to other sites. For links to your own site, we recommend using relative URLs that begin with a /.

Will this work on a multisite?

Our developers are aware of an issue where importing redirects fail on a multisite. Please try the following. Multisites have a custom list of allowed filetypes. We use a CSV file type, which is not on the list. This can be fixed by adding csv to the Upload file types list at wp-admin/network/settings.php. If you are not sure how to do this, your host provider can help.

How to import from the .htaccess file

The third option is to import by copying the contents of a .htaccess file and pasting them into the text box. You can do this by copying the .htaccess file on one site and returning to Import redirects. Paste the file into the box and click the Import .htaccess button below the input field.

Redirects must be in one of the following formats:

Plain redirects

# Redirect [type of redirect, e.g. 301] [source] [target]
# In this example, if a user lands on /family/ (the source)
# they are redirected to /school/ (the target).
Redirect 301 /family/ /school/

Regex redirects

# RedirectMatch [type of redirect, e.g. 301] [source] [target]
# If you go to example.com/rain, you would be redirected to mydomain.com/sunny/
# However, the same goes for example.com/in-the-rain or example.com/draining.
# Both would be redirected to example.com/sunny/
RedirectMatch 301 /rain /sunny/

Did this article answer your question?

Thanks for your feedback!

Related articles

Get free SEO tips!