Home » Tutorials » Wordpress » How to easily do 301 Redirects in WordPress

How to easily do 301 Redirects in WordPress

301 redirect wordpress

In this article we will discuss what is 301 Redirect, when should we use it, the best methods to do redirects in WordPress and as a bonus, we’ll talk about some SEO best practices or how 301 Redirects can help you increase your traffic.

What is 301 Redirect and why should we use it

Simply said, 301 redirect is the best way to permanently redirect one url to another. In that way when you 301 redirect the domain http://example.com/ to http://somedomain.com/ and then when you open example.com, it will load somedomain.com. Hope the explanation is clear enough.

Note: 301 Redirect (permanent redirect) should only be used when you’re truly migrating the url (or whole website) forever. You’re not coming back. If it’s going to be temporary or you might undo it after a while, then you should better use 302 (temporary redirect).

When you do 301 redirect you send both Users and Search engines to the new url. Also almost all of the incoming links and their Pagerank will be seamlessly passed to the new domain.

301 redirect explanation

301 Redirect are really useful and recommended in these situations:

  • You have moved your website to a new domain
  • People access your site through different URLs (duplicate content issue) – if for example your homepage is visible from http://example.com, http://example.com/index.html, http://www.example.com and etc., you should better choose one of these URLs (a preferred one) and use 301 Redirects to send users from the other URLs to the preferred URL.
  • Redirect old posts and pages to fresh, new content (updated version), letting both users and search engines know that we have up-to-date articles in our website.

Is there a limit to how many 301 Redirects I can use on a website?

That’s a good question and thanks to Matt Cutts (the head of Google’s Webspam team) we’ll know the answer.

As a summary I will say that there is no limit of the redirects you can do in one site. But there is one limitation we should keep in mind – Google bot is willing to follow up to 5 multiple levels of redirect. So if you keep that down to one or two, it’s much better.

Also remember that minimizing redirects can improve our page speed.

Creating a Redirect with Plugins

WordPress SEO by Yoast

Wordpress SEO by Yoast

The first plugin, which I totally recommend to use is WordPress SEO by Yoast. Except all the useful features like canonical URLs, permalink cleanup, xml sitemaps, cleaning up the head section and etc., with this plugin you also can easily do 301 Redirects. It offers everything you need to optimize your website.

After you install and activate the plugin, go to your wp-admin area and then open (edit) the post/page you want to redirect. Slide down until you find the WordPress SEO by Yoast tab and click on Advanced.

Yoast wordpress plugin

Paste the url you want to redirect to in the 301 Redirect input field.

301 redirect with yoast

Quick Page/Post Redirect Plugin

Quick page post redirect plugin

This plugin and all its various options allow you to fully control all the redirects in your website. It even offers you to delete all Page/Post redirects at once. Equipped with Redirect Summary page, the plugin show you full statistics of all the redirects you’ve ever done.

redirects summary

Very intuitive interface and very good documentations – that’s all we can say in summary.

So how to do the redirects using this plugin: Again we should click edit on our Post/Page and then find the Quick Page/Post Redirect tab. Paste the URL you want to redirect to in the Redirect URL input field. This plugin’s befits against the Yoast plugin are that it offers you to select the type of the redirect (301, 302, 307 or meta redirect).

redirection types

Redirection Plugin

redirection plugin wordpress

Redirection is a WordPress plugin to manage 301 redirections and keep track of 404 errors without requiring knowledge of Apache .htaccess files. It’s a good alternative to the above plugins.

redirection wp plugin

SEO Redirection Plugin

seo redirection plugin

This plugin helps you to easily build 301,302 or 307 redirects of your Posts/Pages. You can also monitor the 404 Error Pages and redirect them in one mouse click.

seo redirection plugin

redirect 404 pages wordpress

Of course if you do some quick research you can find many other WordPress plugins that offer you to easily do redirects in WordPress. And remember to redirect your old and out-of-date posts to their new versions.

Creating a Redirect With .htaccess

One of the easiest and best ways to do a 301 redirect not only in WordPress, but in any website, is to open the .htaccess file in the root directory of your website via ftp or File manager.

The .htaccess file is a configuration text file used by Apache-based web servers that allows you to control the way visitors are able to access your website.

Note: You have to be very careful when editing the .htaccess file. One minor mistake is enough to bring your whole website down.

You have to be very careful when editing the .htaccess file. One minor mistake is enough to bring your whole website down.

Also you should keep in mind that this method is working only for Apache-based servers.

To redirect a single page open the .htaccess file with your favorite text editor (like Notepad for example) and use the following code:

Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html

Redirect 301 /oldpage2.html http://www.yoursite.com/newpage2.html

To redirect the whole website:

Redirect 301 / http://newsite.com/

Of course if you want to do a 302 redirect (or temporary redirect) you should change the 301 with 302 in the above code.

Edit .htaccess easily using the Yoast SEO Plugin

Although you can edit the .htaccess file from your WordPress admin panel using the WordPress SEO by Yoast Plugin, I would highly recommend you use FTP client to do that. The main reason is that if you break something when editing the .htaccess file then you won’t be able to access this page from the WordPress admin to fix it. Then you will be forced to use FTP.

To easily edit your .htaccess file go to your WordPress admin dashboard after you have installed the WordPress SEO by Yoast Plugin. Then go to SEO -> Edit files as showed in the screenshot below.

Edit htaccess using Yoast

Redirect a Page Using PHP

WordPress uses the PHP scripting language so if you find yourself in a situation where you need to redirect a whole .php page, then add this code to the header:

<?php

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://newpage.com");

?>

If you are developing WordPress themes and/or plugins, take a look at the wp_redirect and wp_safe_redirect functions.

Let me know in the comments below if you have other useful tips for using redirects.

In this article we will discuss what is 301 Redirect, when should we use it, the best methods to do redirects in WordPress and as a bonus, we’ll talk about some SEO best practices or how 301 Redirects can help you increase your traffic. What is 301 Redirect and why&hellip;

Review Overview

0%

User Rating: 4.28 ( 7 votes)
0

About Georgi Dyulgerov

Georgi Dyulgerov

Founder of fTutorials.com - the website aiming to keep you in touch with the latest technologies in the brand. Also a Freelance web developer.

Check Also

wordpress website speed

How to Speed Up your WordPress Site

Site speed is one of the most important characteristics for any product website, blog, online ...

Leave a Reply

Your email address will not be published. Required fields are marked *


Loading Facebook Comments ...