How to Implement 301 Redirects in WordPress

By January 29, 2015Uncategorized

Implementing 301 redirects after launching a new site to replace an old one, or simply if you create a new page to replace an old one, is one of the most important aspects of SEO but, in my experience, it’s often overlooked. Without a 301 redirect, the search engines can’t know that you’ve moved content, so your new pages/website are starting over from scratch in terms of building authority and earning a high rank. Even if your old website wasn’t ranking well and that’s why you’ve launched a new one, you probably had some backlinks that are worth saving.

Actually creating 301 redirects can be done a number of ways. The most efficient way is to put them into your site’s htaccess file. This may seem like a risky move, since the htaccess is hidden and mysterious, but it’s pretty simple when you get down to it.

First, you have to find your htaccess file.

  • Connect to your site via FTP – (I use Cyberduck on my Mac for this)
  • Force your FTP connection to show hidden files (usually just an option in the settings)
  • Locate the htaccess file and open it in a text/html editor (not Word – I use TextWrangler)

If your site is in WordPress, you may not find an htaccess file because WordPress only generates one if you’ve updated the Permalinks settings. You don’t have to change anything there necessarily, just click the Save button.

Once you’ve found the htaccess file, there are two kinds of code that will implement a 301 redirect. The easiest one is simply:

Redirect 301 /old-page /new-page

If your website is MyWebsite.com and you sell widgets, this might look like this:

Redirect 301 /old-widgets-page /new-widgets-page

You don’t have to include the domain name in the code, just the relative URL.

Put this code ABOVE the code WordPress has added to the htaccess file and put each redirect on its own line with no extra spaces at the beginning or end.

Even if you do this correctly, it may not work depending on what WordPress’ code is doing regarding redirects. If you upload your redirect using the previous code and it doesn’t work, try adding this code INTO the block of WordPress code that already exists in the htaccess file.

RewriteRule ^old-page$ http://www.yourdomain.com/new-page [R=301,L]

Update “old-page” to be the relative URL you’re updating at the second URL to the new one. For our previous widget example, this might look like this:

RewriteRule ^old-widgets-page$ http://www.MyWebsite.com/new-widgets-page [R=301,L]

In the context of the WordPress code, this might look like this:

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^old-widgets-page$ http://www.MyWebsite.com/new-widgets-page [R=301,L]

RewriteRule ^index.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress

These methods will work in most sites, though if you encounter complications, contacting your host for support is often the only way to find a resolution.

If all this seems too complicated, well, one of the advantages of WordPress is the extensive library of plugins, and there are several that can handle redirects for you. The popular Yoast SEO plugin even has this functionality.

Leave a Reply