It is important to create 301 Redirects in WordPress whenever you plan to change the URL structure (permalink) of your website’s certain pages and posts or moving your whole domain to a new domain. 301 redirects(permanent) tells the search that the page/post has been moved to new location. And, it shows a new page(redirected URL) to the users visiting your website.
When do we need to Create 301 Redirects in WordPress?
***** When we have changed our old domain name to a new one. For example – when we move to Blogger(blogpost.com) to WordPress we need to redirect old Blogger posts to new URL structure.
***** When we have deleted a post or page, then we need to set up a 301 redirect pointing to the new page. This way, it won’t show a “404 not found” error.
***** We need to set up a redirect when we are planning on changing the permalinks of our WordPress website.
Create 301 Redirects in WordPress
There are several ways using which you can add 301 redirects in WordPress. The simplest way is by using any WordPress redirect plugin. But, if you don’t want to use a plugin, in that case, you can add redirects by editing your .htaccess file. All these methods are mentioned below.
1. Redirection Plugin
Redirection is the most popular plugin for managing WordPress redirects. It automatically checks your website for 404 error pages and then you can redirect them to new pages.
1. Once you have activated the plugin, go to Tools > Safe Redirect Manager.
2. Click on Create Redirect Rule. Under Redirect Settings, enter the URL details. (see screenshot below)
3. Select 301 Moved Permanently under HTTPS status code.
4. Click Publish button on the right side.
3. Set up Redirects by Editing .htaccess file
If you’re a developer or advanced user who doesn’t like using plugins and prefer the manual way of setting up redirection in WordPress. You can add 301 redirects in WordPress by editing your .htaccess file found inside your website’s root directory.
Before performing any changes to the .htaccess file, make sure you backup your .htaccess file. If you don’t know how to backup .htaccess file, please read this guide on how to backup any WordPress files.
So, after backing up your .htaccess file, you’ll have to connect your website to an FTP client like FileZilla. After connecting to your FTP account, you will find .htaccess files inside the root directory(public_html), open the file using a note editor.
At the end of your .htaccess file, add the below code showing you an example for adding a redirect from an “old-page” to a “new–page”.
In the second line, add your old URL in place of old-page(without http://yourdomain.com). In place of new-page, add the new URL you want to create. Also, don’t forget to replace “yourwebsite.com” with your actual domain name. For example – If you want to redirect the URL “https://howtoarticle.in/wordpress-301-redirect” to “https://howtoarticle.in/create-301-redirect-wordpress. Add the code like this at the end of your .htaccess file.
The same way you can add more redirects. Just add another redirect below the first one. This is it. Hope, you have learned to create 301 redirects for your WordPress website. If you find this tutorial helpful, please share it with your friends on Facebook, Twitter, and Google Plus.