Skip to content

How to Create 301 Redirects in WordPress: 5 Ways (2024 Guide)

Last updated on October 13th, 2022 at 11:55 am

If you change the URL of a page after it’s been indexed by Google or move your website to a completely new domain, you could lose out on visitors if you don’t set up a means of redirecting visitors. To do that, you need to know how to create permanent 301 redirects for your website.

Don’t worry, 301 redirects sound more technical than they are. However, they are an important part of any website’s maintenance. They’re used to send visitors (and search engine bots) from one page to another, and they help keep your site organized and running smoothly.

There are a few different ways that you can set up page or site redirections in WordPress. You can use a free plugin, edit your site’s htaccess file, or add code to your functions.php file.

If you’re not comfortable editing files on your server, then I would recommend using a plugin. There are a few different plugins that you can use, but my personal favorite is Redirection. It’s free, it’s easy to use, and it has a ton of features.

I’ll show you five different methods below in this straightforward tutorial. Follow along, and you’ll have 301 redirects set up on your WordPress website in no time!

In a hurry? Jump straight to the how-to guides!

What are 301 (PERMANENT) redirects (and how do they benefit your website)?

Often referred to as a permanent redirect, the 301 redirect code is an HTTP status code that permanently moves a web page to a new URL. If somebody clicks on a link leading to the old URL or types the old URL into their browser, your site will automatically take them to the new URL you set.

When you use permanent redirections on your website, they give search engine bots the message that the old page has been moved to the new page – meaning that eventually, the old URL will disappear from search results completely as the search engine updates the index. Until then, although the old URL might show up in search results, anyone who clicks on the listing will be redirected to the new URL.

Benefits of Using PAGE or SIte RedirectIONS

There are several key benefits of using 301 redirects on your WordPress website:

  • You won’t lose traffic if you change your domain name or merge two websites together.
  • You can redirect visitors to your homepage or another page on your site rather than displaying a 404 error page.
  • You won’t lose your past SEO efforts if you decide to merge two pages on your website into one after performing a content audit – the link equity from the redirected page is passed on to the page you’re redirecting to.

Why You Need TO USE 301 Redirects on Your WordPress Website

If you’re running a WordPress website, there are several situations where you might need to set up permanent redirects.

For example, let’s say you change your WordPress permalink structure from the default setting to something more SEO-friendly, like “%postname%’. Likewise, if you want to change your permalink structure from /%postname%/ to /%category%/%postname%/, then you can use a 301 redirection to send users and search engines from the old URL to the new one.

When you make this change, WordPress can automatically send traffic from your old URLs to your new ones. This ensures that anyone who clicks on a link to one of your old URLs will be redirected to the corresponding new URL.

301 redirects are also often used when content is moved from one website to another. For instance, if you’re merging two websites together, you’ll want to set up 301 redirects so that visitors to the old site are redirected to the new one.

Another common reason to use 301 redirects is when you change your domain name. Let’s say you’re running a website at, and you decide to switch to using instead. In this case, you would set up a 301 redirect from to to make sure that anyone who tries to visit the old domain name is redirected to the new one.

Overall, 301 redirects are an essential part of running a WordPress website. They can help you avoid losing traffic when you make changes to your site, and they can also be used for SEO purposes.

301 redirects vs 302 redirects

Before we dive into how to set up 301 redirects in WordPress, it’s important to understand the difference between 301 and 302 redirects.

A 301 redirection is are permanent redirects. This means that they permanently send visitors from one URL to another. 301 redirects are often used when pages or sites are moved permanently.

302 redirects, on the other hand, are temporary redirects. They send visitors from one URL to another for a short period of time, after which they automatically expire. 302 redirects are typically used when pages or sites are temporarily unavailable.

In most cases, you’ll want to use 301 redirections rather than 302 redirects. However, there may be some situations where you need to use a 302 redirect instead.

For example, let’s say you’re making some changes to your website and you want to put it in maintenance mode for a short period of time. In this case, you could set up a 302 redirect from your home page to a “coming soon” page. Once the changes to your site have been made, you can remove the redirect.

Overall, 301 redirects are the most commonly used type of redirect, and they’re generally the best choice for most situations.

How Long Should You Keep a 301 Redirect Active?

301 redirects are permanent, but that doesn’t mean that you should keep them active forever. In most cases, you’ll want to remove 301 redirects after a year or two.

The reason for this is that 301 redirects can have a potentially negative impact on your site’s SEO. This is because search engines view 301 redirects as a sign that your content has been moved permanently. Because some people will buy expired domains and redirect pages from the old domain to their own websites simply for SEO purposes, search engines can be suspicious of lots of 301 redirects that are in place for a long time.

If you keep a 301 redirect in place for too long, search engines may start to view your site as being unstable, and this could lead to a drop in your rankings.

Therefore, it’s generally best to remove 301 redirects after a year or two. Of course, there may be some exceptions to this rule. For example, if you’re redirecting a domain name that you no longer own, you won’t be able to remove the 301 redirects.

In general, though, it’s best to keep 301 redirects active for a year or two and then remove them. This will help ensure that your site’s SEO is not affected by the redirects.

How to set up a 301 redirect in WordPress – 5 Different methods

There are a few different ways that you can set up 301 redirects in WordPress. You can use a 301 redirect WordPress plugin, your site’s .htaccess file, Yoast SEO, and even straight PHP.

In this section, I’ll show you how to do it using a plugin and without a plugin. In most circumstances, I’d recommend using a plugin as this is the easiest method (and the least likely to go wrong!) However, you can’t use a plugin for all redirects.

Method one: Use a WordPress redirection plugin for page-level 301 redirects

The easiest way to set up 301 redirects in WordPress is by using a plugin. There are a few different 301 redirect plugins that you can use. I recommend using either Simple 301 Redirects or Redirection.

Both of these plugins are easy to use, and they’ll let you set up 301 redirects quickly and easily. They also have other features that can be useful, such as the ability to track 404 errors on your site.

Once you’ve installed and activated one of these plugins, you can start setting up 301 redirects.

For example, let’s say that you want to set up a 301 redirect from your old home page URL to your new home page URL.

With Simple 301 Redirects, you can do this by going to Settings » 301 Redirects and then entering the old and new URLs in the fields provided.

create 301 redirects in WordPress using Simple 301 Redirects plugin

Redirection works in a similar way. Once you’ve installed and activated the plugin, you can go to Tools » Redirection to set up your redirects.

Create 301 redirects with a WordPress plugin like Redirection

Both of these plugins make it easy to set up 301 redirects without having to edit any code. However, they only work at the page level. This means that you can’t use them to redirect an entire site.

If you need to set up a 301 redirect for an entire site, then you’ll need to use one of the other methods.

Other plugins you can use to create 301 redirects

  • Quick Page/Post Redirect Plugin
  • Safe Redirect Manager

Method two: Use a general SEO plugin like YoastSEO to add 301 redirects in WordPress.

Yoast SEO is a popular SEO plugin that can be used to set up 301 redirects in WordPress. It’s a bit more complicated than using a dedicated 301 redirect plugin, but it does have the advantage of being built into an SEO plugin that you might already be using.

To use Yoast SEO to set up 301 redirects, first, you need to install and activate the plugin. Once the plugin is activated, you need to go to SEO » Redirects page and then click on the Add Redirect button.

On the next screen, you need to enter the old URL in the Source URL field and the new URL in the Target URL field.

You can also select the type of redirect from the dropdown menu. The most common types are 301 (Permanent) and 302 (Temporary). If you’re not sure which one to use, then I recommend choosing 301 (Permanent).

YoastSEO create 301 redirects with a plugin

Once you’re done, don’t forget to click on the Add Redirect button to save your changes.

Other SEO plugins like RankMath, AIOSEO, and SquirrlySEO also include the ability to create 301 redirects easily.

Method three: Use htaccess to add 301 redirects in WordPress

Another method of redirecting pages and posts on your website is by editing your site’s .htaccess file. The .htaccess file is a special file that’s used to configure your server settings. It is a powerful tool that can be used for a variety of tasks, including 301 redirects.

You can edit the .htaccess file by connecting to your site via FTP and then opening the file in a text editor. Once you’ve opened the file, you can add the following code:

Redirect 301 /old-page

Redirect 301 /old-post

Just remember to replace old-page and old-post with the actual URLs of the pages that you want to redirect, and to replace and with the actual URLs of the pages that you want to redirect to!

You can add as many lines of code as you need. Once you’ve added the code to your .htaccess file, save your changes and upload the file to your server.

Keep in mind that the .htaccess file is a powerful tool, and if it’s not used properly, it can cause errors on your site. Therefore, I recommend backing up your site before making any changes to your .htaccess file. Furthermore, you should always back up or make a copy of your .htaccess file before you make any changes to it.

If you’re not comfortable editing code, then I recommend that you use one of the other methods for setting up page-level 301 redirects.

When to use .htaccess to create redirects in WordPress

There are several occasions when you should use .htaccess to create 301 redirects in WordPress. These include when you need to:

  • Redirect your website from one domain to another. 301 redirects preserve your WordPress site’s SEO ranking, so it’s important to use them when you migrate a domain, in addition to copying your content to the new domain.
  • Redirect your WordPress site from one subdomain to another. For example, if you want to move your blog from to, then you would set up a 301 redirect from the old subdomain to the new URL.

Redirecting a domain or subdomain with .htaccess

To redirect traffic from one domain to another, you’ll need to add some specific code to your .htaccess file:

<IfModule mod_rewrite.c>

  RewriteEngine On

RewriteCond %{HTTP_HOST} ^$ [OR,NC]

RewriteCond %{HTTP_HOST} ^$

RewriteRule (.*)$$1 [R=301,L,NC]


Make sure that you replace with the old domain name and with the target website’s domain name. Doing this will ensure that all visitors to all URLs on are redirected to the same URL on For example, will redirect to

Expert tip: While you’re editing your .htaccess file, you might want to create a redirect that automatically sends traffic to your homepage instead of showing a 404 error page. To do that, you simply need to add this code to your .htaccess file:

ErrorDocument 404

Bonus tip

You can add code to the .htaccess file to either force or remove ‘www’ from your URL.

Force www with:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^

RewriteRule (.*)$1 [R=301,L,NC]


Remove www with:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^

RewriteRule (.*)$1 [R=301,L,NC]


Use the AIOSEO plugin to edit your .htaccess file

Instead of using FTP and a text editor to add redirects to your .htaccess file, you can easily edit it using the AIOSEO plugin, which enables you to edit the file from within WordPress. You can find the .htaccess editor in the Tools menu of AIOSEO.

After you’ve edited the code, you’ll need to click on Save Changes to apply the new code. Your .htaccess file will be updated by the plugin immediately.

AIOSEO allows you to edit the htaccess file to set up 301 redirects

Method four: Create a 301 redirect with PHP

If you prefer to add redirects without using a plugin or altering your .htaccess, you can opt to manually code the redirects into the PHP of your WordPress theme. While you could add code directly to the header.php file, it’s better to place it in the functions.php file and use a WordPress hook. Adding the code to the functions.php file is more permanent, even if you change themes, whereas the header.php file is affected when you change your theme.

To use this method, you need to connect to your site via FTP and then edit your theme’s functions.php file.

Once you’ve opened the functions.php file in a text editor, you can add the following code:

add_action( ‘template_redirect’, ‘301_redirection’ );

function 301_redirection() {

  if ( is_singular( ‘post’ ) && !is_main_query() ) {

  global $wp_query;

$post_id = $wp_query->get_queried_object_id();

wp_redirect( get_permalink( $post_id ), 301 );




Don’t forget to save your changes and upload the file to your server.

Method five: Use the 301 redirects tools provided by your hosting provider

Most hosting providers will offer a way to create 301 redirects from your hosting control panel. I use Hostinger for all my websites, so I’ll show you how to create 301 redirects in the hPanel. Other hosts may look a little different, but the principle is generally the same!

How to create 301 redirects with Hostinger

It’s really easy to create 301 redirects with Hostinger. Follow these 3 simple steps

How to create 301 redirects expert guide

Total Time Needed :



Steps to set up your 301 redirects in Hostinger:

Redirects in hpanel Hostinger
Step 1: Login to your hPanel.

In hPanel, locate the Redirects menu (it’s in the Domains section)

Hostinger how to create a 301 redirect
Step 2: Set up your redirection

Go to the Create a Redirect section and fill in the URL you want to redirect and where you want to redirect to. Double-check that you’ve selected the correct connection protocol (you should be using HTTPS).

Hostinger how to create 301 redirects
Step 3:

Click Create, and your redirect should show up in the List of Redirects section. Wait a few minutes before checking that your redirection is working correctly (it can take a little while for the redirect to go live.)

Verify Your 301 Redirect

You can check that your 301 redirects are working by entering the old URL into a web browser and seeing if it 301 redirects to the new page. If you see the new page, then it’s working.

You can also check the status code that the page is returning by using the Inspect function in Google Chrome. To do this, type in the old URL and when the page loads, right-click and click on Inspect in the pop-out menu.

Click on the Network tab in the developer tools screen and click on the top entry in the left panel. It should show “301” for the Status code in the right panel. Below is an example from a URL I’ve redirected here on WP Web Whizz.

Check that the 301 redirects you've created are working by using developer tools in Google Chrome

Troubleshooting 301 Redirects

Sometimes you may encounter problems with creating 301 redirects. I’ve compiled a list of the most common issues and their solutions.

I can’t access my website after adding 301 redirects:

This is a common mistake! If you add a 301 redirect to your .htaccess file and it’s not configured correctly, then you will no longer be able to access your website. To fix this, connect to your site via FTP and delete the .htaccess file from your server. Replace it with the original version that you backed up before editing the code. Your website should now load as normal.

I’m getting error messages

If you’re getting 301 errors, then it’s likely that your 301 redirect isn’t working correctly. Check that you’ve followed the instructions in this post carefully and that your code is entered correctly. If the error messages persist, then you may need to reach out to your hosting provider for help with resolving the errors.

My redirects aren’t getting the 301 status code

Try clearing your website’s cache. It could be that you’re viewing a cached page. This is easy if you use an optimization plugin. If you don’t have an optimization plugin, you’ll need to access your website files using FTP and locate the cache folder in wp-content. Open the cache folder and delete all the contents.

Flush the cache via FTP


Make sure you only delete the contents of the cache folder, not the folder itself!

The Effects of 301 Redirects on SEO (and Traffic)

301 redirects can have a negative impact on your SEO and traffic. 301 redirects are permanent, which means that search engines will stop indexing the old page and instead start indexing the new page. This can cause your rankings to drop and your traffic to decrease. Usually, this is only a temporary drop in traffic and ranking, but it’s important to take this into consideration before deciding to apply a 301 redirection.

You should also be careful when implementing 301 redirects on a large scale. If you’re redirecting hundreds or thousands of pages, then it’s possible that Google will penalize your site for what they perceive as manipulative behavior. So make sure you only use 301 redirects when absolutely necessary!

If you do need to use 301 redirects, then make sure you implement them carefully and monitor your traffic and rankings closely afterward.

Summing Up: Creating 301 Redirects in WordPress

Whether you’re doing a content update and want to redirect an old page to a newer page or combine two pages into a single article, or you’re moving your entire website to a new domain, you need to create 301 redirects to ensure you don’t lose (too much) traffic.

Creating 301 redirects is relatively easy, but there are a few things you need to be aware of before you start, such as the potential negative impact on your SEO and traffic. I always recommend using a WordPress plugin to create redirects where possible, but if you’re redirecting a website from one domain to another, you will need to either use code or enlist the help of your web hosting provider.

When used correctly, 301 redirects can be a valuable tool for ensuring that your website visitors always end up on the correct page.

Frequently Asked Questions about How to Create a 301 Redirect in WordPress

  1. <strong>How do I delete a redirect?</strong>

    This depends on the method you used to create the redirect. If you created it using a plugin in WordPress, you can simply delete the redirect that you want to remove in the plugin. Look for either a trash can icon or a delete button, or link next to the redirection.

  2. <strong><strong>Can I use a 301 redirect for any URL?</strong></strong>

    Yes, you can use a 301 redirect for any URL on your site. However, it’s important to only use 301 redirects when absolutely necessary. Overuse of 301 redirects can have a negative impact on your traffic and SEO.


    No, you don’t need to know any code to create a 301 redirect in WordPress. You can create redirects using a plugin or by using the redirection tools in your hosting control panel.

  4. <strong>HOW DO I KNOW IF MY 301 REDIRECT IS WORKING?</strong>

    The easiest way to check if your 301 redirect is working is to use a tool like the Redirect Checker. Simply enter the URL of the page you’re redirecting, and it will show you the status code of the redirect. If it’s 301, then it’s working correctly!You can also check the status code using Developer tools in Google Chrome.

  5. <strong>WILL A 301 REDIRECT SLOW DOWN MY SITE?</strong>

    301 redirects can have a slight impact on your site’s performance. However, this is usually negligible and shouldn’t be a cause for concern. If you’re concerned about your site’s performance, then you can try using a caching plugin to speed things up.

  6. <strong>HOW DO I FIND OUT WHAT MY 301 REDIRECTS ARE?</strong>

    If you want to see all the 301 redirects on your site, then you can use a tool like Screaming Frog. This will give you a list of all the 301 redirects on your site. You can also check your server logs to see all the 301 redirects that have been issued.

  7. <strong>DOES A 301 REDIRECT AFFECT SEO?</strong>

    It can do, but this is generally only a temporary effect when the 301 redirection goes live. You may notice that your website traffic decreases, and you may lose your positions in search engine results pages (SERPs.) Usually, within a few weeks, you’ll see your traffic and rankings return to the levels you were seeing before you implemented the redirection. As long as you use 301 redirects wisely, there shouldn’t be a long-term effect on your SEO.

How do I add wildcards or folder redirects?

You can create wildcard redirects (sometimes referred to as ‘catch-all’ redirections) by manually adding code to the .htaccess file. By adding an asterisk to your code, you’re adding a wildcard redirection. For example, you might use this code if you move the /blog section of your website to /news:

RewriteEngine on

RewriteRule ^blog/(.*)$ /news/$1 [L,NC,R=301]

Using this code means that anyone visiting will be redirected to In addition, visitors to will be redirected to

Grammarly Writing Support

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 21

No votes so far! Be the first to rate this post.

Martyn Denial

Martyn Denial

I've been building websites with WordPress for over 10 years, and now I spend my days giving advice to others on how to make the most of WordPress for their websites. I'm also experienced in SEO and affiliate marketing, but WordPress is what I do best!View Author posts

Cookie Consent Banner by Real Cookie Banner