The Intermediate Guide to 301 Redirect WordPress via .htaccess and Plugin
Last updated on August 10th, 2021 at 01:47 pm
A redirect is used to redirect users from one web page to another automatically. It is ideal when everything on a web page, starting from content and media to load time, remains the same, but the link to the page changes.
However, achieving an “ideal” state in any task is a tedious task, isn’t it? Don’t worry; you will be able to redirect web-pages on WordPress efficiently, by the time you complete this article.
Tale of a blogger without redirect
Sally is a blogger in the fashion and apparel industry. She has always had a knack for upcoming fashion, and that’s why she started writing a blog about it on WordPress. Since Sally is so good at her job, people love her and traffic increased at a fast rate.
Now, Sally wants to provide a more secure platform for her content consumers so that she can have secure data transactions with her consumers. Also, since she’s in the fast-paced fashion industry, her old blogs have turned stale, and she has new spicy blogs ready to update them, but she’s afraid that she’ll lose her traffic if she creates a new web page. Moreover, if she deletes the old web-page, her viewers coming from different search engines and social platforms will end up seeing a “404 – Page Not Found.”
Also, since the fashion industry is all about mixing and matching different products, it’s a very tough task for Sally to drive traffic from different product blogs to a new blog of their combinations.
All of Sally’s concerns are genuine and are problems of many blogger lives. These are some reasons why bloggers continue to have all their traffic distributed over multiple web-pages, and quite a few of their viewers end up consuming outdated content.
The solution of redirection
A redirect equips Sally to tackle all her problems in one go. Through redirect, she can take her website from an HTTP server to more secure an HTTPS server and can carry out any types of transactions. She can also redirect her old web pages to new ones so that users always consume updated content. This way, she’ll all of her traffic on a single, secure, and updated web-page.
Since this is such a significant concern for all bloggers and developers, there are various solutions to implement a redirect. But let’s see what type of redirects you’ll need.
301 redirect and 302 redirect
There are two types of redirects that bloggers need to know. One of them permanently redirects the web address while the other one redirects it temporally. 301 redirects is used for permanent changes, and ‘302 redirect’ is used to transfer users to a web-page on a temp basis.
For example, Sally is pretty sure that a product by company A is better than an outdated but competitive product from company B. So, she 301 redirects all her users from the old blog about company B’s product to the new blog about customer A’s product. This way, she notifies users and search engine crawlers that the URL has changed and has a new destination. 301 redirects is not recommended if the source web-page might be of any use in the future.
On the other hand, when Sally feels that she can try something new with her audience, she 302 redirects them to a new page. This allows her to test new ideas on her audience, having the liberty of switching back to old pages, which were already liked by her viewers.
Let’s understand how you can create “ideal” 301 redirects.
301 redirect WordPress via .htaccess
One of the ways is by editing the .htaccess file of your website. The .htaccess file is a map of your website. It is also known as the webserver configuration file. Since a server hosts this file, you’ll need to have FTP access and login credentials for viewing your server through an FTP client such as Cyberduck or Filezilla.
After logging in, you can find the .htaccess file in the root folder of your WordPress website. The root folder contains some important files such as “license.txt” and “index.php,” i.e., your homepage. So, it’s recommended to think twice before making changes to your website after this stage.
The visual depicts how the root folder will look like. There might be a higher or a smaller number of files inside your root folder. If you can’t find the .htaccess file, it’s probably hidden, and you can change that setting by exploring the “Options” menu under the “Tools” tab.
There is also a very tiny probability that there is no .htaccess file. Hence, you’ll have to create one. You can easily make one through the FTP editor and name it as “.htaccess.” Also, don’t forget to set it’s permission to 644 as required by WordPress.
Download the .htaccess file and make a copy of it. If there’s some problem with your .htaccess file, WordPress will not be able to process your website and return the user to an “Internal Server Error” page. So, it’s better to make changes in a copy and keep the original as a backup. Now, open the copied .htaccess file on a notepad to edit it.
There could be a higher number of lines in your file from the different plugins that you have installed. But the basic file looks something like this. The task at hand is to edit this given file for redirecting from an outdated link to a new link.
To redirect a user from one single post or a web page to another, you can use the following code:
Redirect 301 /outDatedLink https://domain.com/newLink
Where “outDatedLink” is the link that you want the users to redirect from and “newLink” is the destination link. For example, if you’re going to redirect viewers from link1 to link2 on your website domain.com, you’ll write the following code on your .htaccess file:
Redirect 301 /link1 https://domain.com/link2
If it is required to shift the whole domain from domain1 to domain2, it is possible by editing the same .htaccess file. You just have to run the following code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1 [NC,OR]
RewriteCond %{HTTP_HOST} ^domain1 [NC]
RewriteRule ^(.*)$ https://domain2/$1 [L,R=301,NC]
The command preserves the overall schema of the domain i.e., the website while making the switch. That implies that the page at domain1.com/contact automatically changes to domain2.com/contact.
But is it always so onerous each time a redirect is to be made? Well, yes and no. If you’re looking to change domains, you’ll have to go through the .htaccess file, but for all other tasks, there are a couple of plugins that make life much more comfortable.
Plugin solutions to implement 301 redirect WordPress
The most straight forward way to create a redirect is by installing a WordPress plugin. The best part about using plugins that they have a user interface to interact with, alongside all their free services.
WordPress Redirection Plugin is a plugin that has been available to the market for more than ten years. It is compatible with a small number of redirects to redirects in a massive amount.
With a simple user interface, WordPress Redirection plugin provides a great user experience. Redirecting web-pages is as simple as creating a contact on your cell phone for a new number. WordPress Redirection Plugin also enables you to track all your 404 logs, i.e., track whenever your users didn’t get what they came looking for. Also, it helps you to monitor how many users got successfully redirected to the new page.
With all the cool services for free and a simple user interface, WordPress Redirection Plugin seems to be a good solution for redirect problems unless you want to change your whole domain.
Page Links To
Page Links To is an easy to install plugin that enables you to redirect a page. The plugin adds a meta-data box on the edit screen of your post, where you can directly enter the link for a redirect.
Simple 301 Redirects
Simple 301 Redirects, a WordPress plugin that equips bloggers to make redirects and also change domains. This plugin is an all in one package with all functionalities for free. Simple 301 Redirects plugin can is also used for changing domains, while the website schema remains preserved.
By checking the wildcard checkbox, high order redirects are possible. The “travel” directory on the “old-page” is now the “adventure” directory on the “new-page.” The asterisk is a regular expression used to match all strings i.e., file names.
Are redirects bad for SEO?
Redirects are in no way bad for search engine optimization algorithms. But if not implemented correctly can cause a ton of chaos for SEO engineers. Also, if you’re sceptical if crawlers will get to your new redirects or not, you can always update the Google Webmasters Search Console. Updating the console notifies Google’s crawler about your redirect, and you need not worry about impending traffic.
Google is pretty smart; hence, it picks up the redirects automatically, but if you want to speed up the process, you can update the console.
Happy Ending
In the end, Sally ends up redirecting and clubbing web-pages to drive secure and large amounts of traffic. The best way to ensure consistent traffic is by maintaining redirects whenever you create new content on the old topics. They also help you to provide a more secure platform through HTTPS.
All of this comes at no cost and is absolutely free. A habit of creating redirects whenever new content is created will definitely help you to club and control your traffic in a better way.