I migrated a site with over 500 posts from Wordpress to Craft 2.6 recently but came across this problem: the WP site used to set post's urls as https://mysite.com/{slug} while the new blog is (correctly) saving them to https://mysite.com/blog/{slug}.

The problem is, a lot of the post entries have great SEO positiong and I don't want to lose that, what is the best way to achieve this?


Migrating Redirects should not be thought of as a one-time event but a process that includes a step where you make sure Redirects are in place and working.

A rough redirect strategy

  1. Take a snapshot of where your old website stands. This can be a combination of using tools like Google Analytics, Screaming Frog, moz.com, raventools.com, or one of many other services that do similar things. The main goal of this step is to understand where your current website ranks and what errors your current website has. Whatever you do in this step, you're going to do it again after you launch and by understanding your baseline before you make significant changes you'll have a better picture of what may need correcting after you launch the new site.
  2. Identify all the URLs that are changing and decide which ones you want to redirect. Often this is all of them. Sometimes, you might choose to clean things up or just focus on key pages. Redirects can be managed in various places. The easiest place to manage them may be via a plugin like Sprout SEO or Retour however managing them via the .htaccess file or some other lower level configuration is also an option. A good way to consider which URLs need redirected is to look at your analytics data. You can filter Google Analytics data and get a list of all pages that have been visited in the past year ordered by page views to get a fairly accurate list of what's important that you should be caring about.
  3. Get redirects in place. If you have a few redirects, adding them manually may be fairly straightforward. If you have lots, consider using regex patterns in your redirects. If a group of pages changes their URLs in the same way, you can likely write a single rule to match all of their URL patterns and forward those old pages to the new ones. I've given a more specific example of this below.
  4. Once you go live, be sure to test your redirects (see notes below) and take another snapshot of your site and monitor the site for unexpected behavior. Google Search Console and various tools like the ones mentioned above can help you monitor the site for errors and make sure no big issues were accidentally introduced. Sprout SEO can help you capture all 404 Redirects and an admin can convert any pages that were missed into 301 Redirects. When you do find issues, be sure to address them as quickly as you can. The longer you let them sit, the more likely search engines will think they are the norm.

A few additional notes on redirects

There are different types of redirects. If you set a redirect to be a 301 redirect, that rule will get cached in your user's browsers. If you happen to make a mistake and try to change your redirect, the only way a user that hit your last redirect will get rid of it is if they clear their browser cache. For this reason, I recommend starting out with 302 redirects and testing all redirects as 302s. If the redirects work as expected, you can then update them to 301 redirects to signal to search engines that your changes are permanent and reduce the change that you create a scenario where incorrect rules get accidentally cached in user's browsers.

If you have several redirects that follow the same pattern, you can use regexes to simplify the number of redirects you need. The following example is an .htaccess redirect that will match all incoming article/{slug} URLs and redirect them to a new blog section (the term used in regexes for matching patterns within parentheses is Capturing Groups).

RewriteRule ^/article/(.*)$ /blog/$1 [R=301,L]

In your case, since the previous URL was very broad {slug} it may be challenging to find a pattern that matches your old URLs that doesn't also match all of your new URLS or new pages on your site. In this case, you may need to be more explicit in which URLs you are redirecting

If you do need to import 500 URLs, Sprout SEO Redirects can be converted from CSV and imported via Sprout Import.


Use a plugin like Retour to do a 301 redirect.

  • Yes, I've used it before but I'm not sure if there's a way for me to not have to enter 500+ redirects manually.
    – brunouno
    Apr 1 '18 at 15:50
  • 3
    RegEx is your friend! Apr 3 '18 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.