How to Complete a Mass 301 URL Redirect in Magento

posted on November 4, 2014 12:46 pm in ,
Magento 301 Redirect

A key consideration when building a new Magento website is your SEO migration strategy. One essential component in this strategy is URL migration. Whether moving from a different platform to Magento or upgrading to a newer version of Magento, you must make sure that a URL migration is conducted so as not to lose any valuable rankings that you currently have in Google and other search engines.

Once you have uploaded your products to Magento, you will potentially have a list of new URLs for them. If that is the case, it is necessary to redirect your old URLs to the same page on the new site. This is where we use the “301 redirect” extension for your URLs, which essentially tells the crawlers of a search engine to remove the old URL and replace it with the new one. In addition, it will also automatically redirect anyone who visits the old URLs to the new one.

If you have a small amount of products, you can easily get by using the URL rewrite management feature of Magento. However, it is probably not a good solution for redirecting thousands of URLs considering the time required to get the job done.

Managing mass configuration in Magento, including 301 redirect is a skill on its own, independent of your general data entry or programming skills. In particular, knowledge of Excel or OpenOffice Calc coupled with the understanding of the Magento basic product structure of the new Magento site will ease the .csv file creation process required for the mass configuration in Magento.

To complete the mass 301 redirect in Magento, you can use these following steps:

1. Prepare a spreadsheet with the list of old URLs and new URLs. If you are an agency, you can ask
your client to provide you with this spreadsheet. The file will have two columns, a column for the old URLs and another column for the new target URLs.

2. The spreadsheet in step 1 will be used as the basis for the URLs import. You need to prepare a new spreadsheet file with additional fields and adjustment.

• First, copy the list from your first spreadsheet to the new one.
• Ensure the column containing the list of old URLs is named “request_path” and the column
containing the list of new URLs is named “target_path”.
• Add a new column called “store_id”. To fill in this column, you will need to open the backend of
Magento, open the store_view from System > Manage Shops.
• In the example (see figure 1 and 2), the store ID is 1, so you can populate the cells in
“store_id” column with this value.


Figure 1. Open default store view from System > Manage Shops


Figure 2. Find the store ID from the URL path.

3. Add a new column called “id_path”. This is a unique id for a particular URL rewrite. You need to use the format “custom/XXX” where you can replace “XXX” with unique number for each line.

4. Add another column called “options”. Fill in every cells with “RP”

5. Rearrange the columns as follows: store_id, id_path, request_path, target_path, options

6. Save the spreadsheet as .CSV with (,) as field delimiter and (“) as text delimiter.


Figure 3. Example csv. file for the import.

7. Go to the database of your shop through PHPmyAdmin and open table “core_url_rewrite” and go to the “import” tab. Find the saved spreadsheet and make sure you choose partial import and skip the first row (start the import from row 1 instead of 0).

8. Type in store_id, id_path, request_path, target_path, options.

9. Click Go and you are done. Double check for any broken links.

There are other ways to do mass importing using additional third party module or .htaccess. Using .htaccess file is a less desirable alternative because it is parsed for every request and can slow down your website which is bad for SEO. So now you have the knowledge to optimise your new site, take your time to do this URL redirect because it is worth it!