How to Create a 301 Redirect in WordPress 1

How to Create a 301 Redirect in WordPress

Have you ever clicked on a link to be greeted by a 404 page reporting that the content you’re looking for has moved? It’s annoying, isn’t it? This is exactly why you want to make sure this never happens to your website visitors.

If you change the URL of your website, or even the URL of a single page on your site, you can redirect your visitors to the new URL so that they continue to access that content. And that’s exactly what 301 redirects are for.

In this article, we will show you how to create 301 redirects in WordPress. The topics we will talk about are:

First, let’s take a look at what the “301” in a 301 redirect actually means.

What Are HTTP Status Codes?

Simply put, a 301 is an HTTP response status code that indicates that the page we requested has been permanently moved to another location. And a 301 is just one of many HTTP responses that tell us what’s going on in a URL.

You see, when you want to access a particular page, your browser sends a request to that website’s server. and there is five classes of HTTP response status codes that a server can send to the browser: 1xx (info response), 2xx (successful), 3xx (redirect), 4xx (client error), 5xx (server error).

The fastest way to check the HTTP codes on your own website is to press the F12 button and then Network tab.

For example, if everything works like a charm, a server will respond with a 2xx HTTP status code, which means that the requested content will be successfully served to the visitor.

HTTP Status Code

when it comes 3xx HTTP response codesthey indicate that a page has been removed and users will be redirected to the new URL. There are several types of redirects. The most commonly used are:

Why Do You Need 301 Redirects on Your WordPress Website?

If you decide to use a 301 redirect, all existing traffic will be seamlessly transferred from the old URL to the new one. You won’t lose any leads or potential conversions. In fact, Gary Illyes, one of Google’s webmasters in 2016, Confirmed that 3xx redirects don’t lose PageRankwhich means they are just as powerful as the original page or post.

Some of the most common reasons you might want to use a 301 redirect these are:

How Long Should You Keep 301 Redirects Active?

Google’s webmaster, John Muller, discussed the question: How long does it take to keep the 301 redirect active During a hangout in 2015. That said, theoretically, you could keep a 301 redirect forever, as that redirect is permanent. But it’s good to remember that It takes some time for Google (and other search engines) to detect that a website has moved. Mr. Muller’s advice, keep the redirect for at least a year or possibly a little longer, depending on your situation. If you remove the 301 redirect sooner than that, Google may continue to show the old URL, especially if there are external links on the web.

How to Set Up 301 Redirects in WordPress with .htaccess

The .htaccess file is a configuration file and one of the core files of a WordPress website.. Needless to say, any changes you make to the file should be done very carefully.

The .htaccess file tells servers how to handle certain things on your website.. A website can have several .htaccess files, but the one we’re really interested in is Located in the root or central directory of your WordPress website.

To find and access an .htaccess file on your site, you must log into your server using an FTP client. If you’re not sure how to do this, check out our FTP getting started guide. The dot next to the file name indicates that the file is hidden. Please note that this file is hidden by default. To find it, edit the settings in your FTP client to display hidden files.

Now that you can see the main .htaccess file, Be sure to back up its content before making any edits.. To do this, right-click on the file and select it. download (Depending on your FTP client, you may see a different option, eg. Add to download list, etc.). You can also copy and paste the file to your computer.

To start making changes to the file, right-click on it once again and To organise.

HTTP Status Code Editing

Redirect a Page or Post to Another Page or Post

First, let’s see how to create a 301 redirect of a post or a page on the same domain. In such cases, this is the code you need to add to your .htaccess file:

301 old url redirect new url

Add the old URL first, then the new one. You can redirect as many times as you want, just copy this code and add the relevant URLs.

Redirect Your Website From An Old Domain To A New Domain

Whenever you want move your website to a new domain and create a 301 redirect for it, you need to edit the old domain’s .htaccess file using the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ https://www.newdomain.com/$1 [R=301,L]

Be sure to change the URLs to match your old and new domains.

HTTP to HTTPS redirect

To keep your website secure and protect your users, you should run it under HTTPS and add a valid SSL certificate to it. if you want move a website from HTTP to HTTPS, you also need to route traffic from the first to the second. The best way to do this is to use a 301 redirect. as recommended in this video, again by John Mueller from Google. Add the following code to the main .htaccess file to create a 301 redirect:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Again, change the URL to match yours.

How to Create 301 Redirects Using Plugins

If you are not comfortable changing the main .htaccess file, you can create 301 redirects using a WordPress redirect plugin. We bring you 5 plugins that we believe work best.

1. Routing

redirection The WordPress plugin is definitely the most popular plugin on the list with over 1 million active installs. It’s been around for over 10 years and is a great choice for creating 301 redirects. This plugin allows you to monitor 404 errors on your website and includes configurable log option among many useful options. Configurable logging allows you to browse referrals occurring on your website and learn about your visitors about their location, browser they use, etc. It allows you to get information such as

Activate the plugin after the installation is complete. then go Tools > Forwarding.

Redirect Plugin

Here you can enter the source and destination URL and create redirects according to your requirements.

Redirect Plugin Settings

2. Simple 301 Redirects

this Simple 301 Redirects The plugin has over 300,000 active installs and is incredibly easy to use.

To create a redirect (after installing and activating the plugin), navigate to: Settings > 301 Redirects.

Simple 301 Redirect Plugin

There are two boxes, one for the old URL and one for the new URL.

Simple 301 Redirect Plugin Settings

If you wish, you can also use Wildcard redirects. To enable them you just have to check the box under the URLs and Save Changes.

2nd Place Mathematics

Rank Math It is a great SEO plugin that can also be used to effortlessly create redirects.

For starters, go to: Rank Math > Redirects.

Sequence Math Routing

If you don’t see the option in the submenu, go to: Sorting Math > Dashboard and enable Redirects choice.

Turn on Rank Math redirect

Next, select add new and set the new redirect.

New redirect 301

This plugin is a great choice for creating redirects the easy way, but you can also use Rank Math as your SEO plugin.

4. Fast Page/Mail Forwarding Plugin

As the name suggests, Fast Page/Post Redirect Plugin It allows its users to create quick redirects. Currently, this plugin has more than 200,000 active installs.

Once you have installed and activated the plugin will appear in your admin menu. Hover over it to see the options it contains.

Quick Page Post Redirect Plugin

Click to add new redirects Quick Redirects. Then paste the old and new URLs. When you’re done, click Add New Redirects.

Quick Redirects Add New

5. Secure Redirect Manager

With more than 50 thousand active installations, Secure Redirect Manager It is the last redirect plugin we will present on our list.

After installing and activating the plugin, navigate to: Tools > Secure Redirect Manager.

Secure Redirect Manager Plugin

Click on it and then Create Routing Rule at the top of the page.

Secure Redirect Manager Settings

After that, the appropriate URLs redirect and redirect fields.

Secure Redirect Manager Settings

Under Redirect Settings > HTTP Status Code choose 301 Moved permanently.

Secure Redirect Manager Settings

When you’re done, press Publish for the changes to take effect.

To summarize

301 redirects are incredibly helpful and can positively impact your users’ browsing experience. People won’t be too happy if they can’t find the web page they’re looking for, so it’s in your best interest to redirect them to a valid URL. Setting up 301 redirects is also a great way to ensure that the link right is transferred from an old page to a new one. That’s why we wanted to show you how to create a 301 redirect page in WordPress so you can get your users to the right place.

Don’t go overboard with the redirects though. Your top-level domain must not have more than one 3xx page. Use them only when necessary because can increase page load timeit also negatively affects your user experience.

Support our work ❤️

If you enjoyed this article, consider leaving a tip to help us keep publishing great content.

Secure payment on PayPal
Moyens I/O Staff is a team of expert writers passionate about technology, innovation, and digital trends. With strong expertise in AI, mobile apps, gaming, and digital culture, we produce accurate, verified, and valuable content. Our mission: to provide reliable and clear information to help you navigate the ever-evolving digital world. Discover what our readers say on Trustpilot.