How do I 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.

Where can you find the redirect import 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. Log in to your WordPress website.

    When you’re logged in, you will be in your ‘Dashboard’.

  2. Click on ‘Yoast SEO’.

    On the left-hand side, you will see a menu. In that menu, click on ‘Yoast SEO’.

  3. Click on ‘Tools’

    The ‘Yoast SEO’ settings will expand providing you with additional options. Click on ‘Tools’.

  4. Click on ‘Import and Export’.

  5. Go to the ‘Import redirects’ tab.

  6. Choose an import method.

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

Import from a supported redirect plugin

The first option is to import from the following plugins:

Note: With Redirection, Yoast is expected to import Groups and any Regular Expressions (either as part of a group or not).

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

Only use REGEX redirects if you know what you are doing!

If you are not sure what REGEXs redirects are, learn more about them here.

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. Till a fix is ready, please try this workaround: 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.

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 then going to SEO-Tools-Import/Export-Import Redirects (it is a tab). Then 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/

Related articles

Get free SEO tips!