Back to blog

Sometimes it happens that you need to redirect visitors to another part of the site (if they visit a specific page or post). There may be various reasons: changing the address of a link (URL) to a page or post, deleting it, etc.

Redirection (Redirect) in a Nutshell

A redirect is needed in order to forward users to another URL (page or post) other than the one they originally requested.

301 Permanent Redirect allows you to redirect users and search robots from one URL of your site to another. But in which cases it is used most?

  • Configure mirrors: redirect from www URL to a URL without www;
  • If your site moves from one domain to another;
  • When changing the CMS (content management system);
  • When changing one URL to a more user-friendly URL.

At the same time, 301 redirect for 90-99% transfers all the properties of the old page to the new address. That is, in fact, it sticks together two URLs.

How to Create a 301 Redirect in WordPress?

  • 301 Redirects via .htaccess

One of the main ways to add 301 redirects is to edit the .htaccess file on the server.
Changed configurations become more difficult to maintain over time, especially if you are a productive blogger or if you are trying to improve the search engine optimization of your publications you need:

  • Log in to the server via FTP,
  • Edit the files,
  • Re-upload them to the server every time you need to add a new redirect.

Remember that 301 redirects need to be configured when you finally move a website or a separate page to a permanent new address. While 302 redirect, provides a path to a temporary page.

  • 301 Redirects via PHP

There are two options. Either you redirect by changing the file Header in the code, or you use the redirect function built into the WP console.

An example of a simple PHP redirect by changing the file Header can be:

// Permanent 301 redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.my-blog.com/a-new-destination");

And here is how the redirection is performed using the built-in function:

wp_redirect( 'http://www.my-blog.com/a-new-destination', 301 );

If you forget to specify “301”, both PHP and WordPress will consider that this is a 302 redirect, which is not always true.

  • 301 Redirects Using Plugins

To facilitate the creation of redirects, you can use special plugins for WordPress (Redirection, Htaccess404 to 301, Simple 301 Redirects, etc.).

As a rule, they have a built-in manager that allows you to reassign address links for publications, pages, or any element of systematization of the site, which can potentially lead to a 404 error if you do not specify the correct redirection.

How to Register 301 Redirects in WordPress Using the Htaccess Plugin:

1. Find and install the plugin.

2. After activating the Htaccess plugin, go to “BWS Panel” – “Htaccess” control panel and switch to the “Editor” tab.

3. Enter the code in the “Customize .htaccess File” field and save the changes. 301 redirection is configured.

After you have created a 301 redirect, check the site for performance. One small mistake can make your entire site inaccessible, so it is a good idea to create a backup of the .htaccess file before making any changes to it. Simply mark the “Create htaccess-backup.txt” checkbox. In case anything goes wrong, you can always restore the original settings from the file by clicking the “Restore .htaccess to Backup” button.

Summing Up

The presence of duplicate content causes confusion for both users and search engines.  301 redirects are meant to solve such kind of issues. Moreover, a 301 redirection is the key to maintaining a website’s domain authority and search rankings, when the site’s URL changes for any reason.

Popular Posts

Like This Article? Subscribe to Our Monthly Newsletter!

Comments are closed.