How do I import redirects using Yoast SEO Premium?

Yoast SEO Premium includes the option to import your redirects from popular redirect plugins, from a .CSV file, or from an .htaccess file.

  1. Log in to your WordPress website.

    When you're logged in, you will be in your 'Dashboard'.

  2. Click on 'SEO'

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

  3. Click on 'Tools'

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

  4. Click on 'Import and Export'. 

  5. Select 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 an .htaccess file.

Import from a supported redirect plugin

The first option is to import from the following plugins:

Yoast SEO Tools Import Redirects

Import from a CSV file

The second option is to import from a custom CSV file. This method requires that the syntax and format is 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 here: Yoast SEO redirect example

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!

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

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.

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 /.

Import From the .htaccess file

The third option is to import by copying the contents of an .htaccess file and pasting them into the text box.

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/

Was this article helpful? ·