Link to home
Start Free TrialLog in
Avatar of lonnyo
lonnyo

asked on

Redirect old blog posts to new blog

I need to redirect an old wordpress blog to a new wordpress site.  We converted the regular site to a new wordpress site and have moved all the blog posts from the old blog to the new site.

The old site links look like this:
http://www.tmicoatingsblog.net/archives/1658


The new site links look like this:
http://www.tmicoatings.com/fertilizer-tower-painting-by-tmi/

The sample links above are for the same post. Unfortunately, when the blog posts were moved over, the shortcodes are not the same value as the old blog (which is the number appearing in the old url).  I tried searching this on the internet and thought I had a solution, but nothing seems to be working.  I am looking for a solution so I don't have to do every redirect by hand.  There are over 500 redirects.
ASKER CERTIFIED SOLUTION
Avatar of Jason C. Levine
Jason C. Levine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lonnyo
lonnyo

ASKER

I tried switching the old blog's permalinks to post name, but when I did that the old links were broken. Not sure if there is a way to make that work.
Not really. This is the kind of thing you have to decide very early on in the blog's life.  Switching it now won't help you.
Here's what I'd do:

1.

Export the old posts (id, title). You can do this direct from the DB or using a plugin like https://wordpress.org/plugins/export-to-text/

2.

Put this data in an excel workbook on sheet 1

3.

Export the new posts (id, title, permlink), using same method mentioned above, from the new site

4.

Put this new data in a second sheet in the same excel workbook
Now, on a third sheet using vlookup you'll use the "title" (since it matches between both sites) as the commonality to set up these columns:

1.

Title - this can be pulled from either sheet since they should be identical

2.

ID - this is pulled from the old data and needs to be matched with its respective title

3.

Permlink - this is pulled from the new data and needs to also be matched with its respective title
Now you have a sheet that contains two critical mapping components:
The old ID (Ie. the 1658 seen in this url: http://www.tmicoatingsblog.net/archives/1658)
The new permlink (ie. the fertilizer-tower-painting-by-tmi http://www.tmicoatings.com/fertilizer-tower-painting-by-tmi/

With this, you can easily create an htaccess file that contains a 301 redirect for all the old IDs mapped to the new url.

The old site htaccess would look like something like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} /archives
RewriteRule ^(.*) http://www.tmicoatings.com/archives/%{REQUEST_URI} [R=301,NC]

Open in new window



The new site htaccess would have around 500 lines similar to this that you'd have created via excel:
Redirect /1658 /fertilizer-tower-painting-by-tmi

Open in new window