Redirect After Migrating To WordPress

Despite your best efforts, your file structure, image locations, and URLs will probably change after migrating your old site to WordPress.   You could manually redirect old URLs to their new WordPress locations using .htaccess.  This can be tedious if you have hundreds of posts.  Choosing to focus on your most popular content could streamline things a bit.  Determining which files deserve redirection can be accomplished using Google Analytics or a plugin.  Once you’ve identified which files to redirect, you can manually create your redirects by modifying your .htaccess file or using a plugin to create the redirects for you.

Finding Your Most Popular Pages Using Google Analytics

You can download a CSV file of your most popular content by navigating to the Behavior report in Google Analytics.  Open the All Pages tab under Site Content and select and time frame for the report; 3 to 6 months would be a good start.  Click on the Export link at the top of the page to download the file.  You can use this CSV file to begin creating your redirection for popular content.

Monitoring 404 Pages Using Google Analytics

There are several ways to track 404 hits in Google Analytics.  The first method is to navigate to Behavior => Site Content => All Pages.  Once there, select Page Title link beside the Primary Dimension filter, which is located on the left just above your page listings.  To display a list of 404 hits, enter a portion of the title of your 404 page.  In our example, our 404 page title starts with “Nothing found for”.   This search returns a list of all pages that start with “Nothing found for”.  If you used our guide for creating a custom 404 page that offers visitors content suggestions based on the missing page title, you’ll also be able to see how effective your 404 page is by reviewing the Bounce Rate column.

Another method to view 404 hits in Google Analytics is to create a Custom Report that essentially automates the method above for you.  There’s a great guide for creating a custom report for 404s available at Search VIU

Creating 301 Redirects Using .htaccess

Once you have a list of the pages that need redirection, you can add the following to your .htaccess file.  Just include a RewriteRule for each page needing redirection.

<IfModule mod_rewrite.c>
RewriteRule ^oldwebpage$ [R=301,L,QSA]

Be sure to add this code above the section that begins with # BEGIN WordPress

Creating 301 Redirects Using Redirection Plugin

Even if you are trying to limit your WordPress plugin usage, the Redirection plugin can streamline both creating URL redirection and monitoring 404 page hits.   You can export your redirects and delete the plugin once done, and still stay “plugin-lite”.  Because you can export your redirects and add them to your .htaccess manually, you can let the plugin do all the hard work for you and delete it when done.  Just set a time frame, such as 3-6 months, for when you think you won’t be needing the plugin anymore.

To really get the full benefit of the plugin, be sure to enable the 404 Logs under the Options section.  You can set it to log 404 page hits for a day, a week, etc.  This can definitely increase database usage, so select a setting that works for your site.  The key benefit to this option is you can create redirects directly from the 404 listing page.  The only downside to the 404 logs is that they include hits from spiders and bots, and 404 hits for images, .js, .css, etc.  A filter to exclude file types would be beneficial.

Redirection Pros

  • Ability to export the redirections and hardcode them into .htaccess when you’re ready to delete the plugin
  • Monitor 404 page hits
  • Group 404 entries to see which are getting the most hits
  • Create redirection directly from 404 log page (including deleting all matching 404 log entries)
  • View how often redirects are being used; how effective they are