In some cases, users will visit one URL only to be sent to another. That’s called a ‘redirect’ and it enables you to reroute traffic when you don’t want visitors to access a particular page. A WordPress redirect can come in handy in a lot of situations, but it can be tricky to implement one.

Using redirects can save your visitors from making their way to pages that aren’t ready yet, or potentially outdated. They get to see the content they really need, and you avoid angry users wanting to leave your website.

In this article, we’re going to talk a bit more about what redirects are and what types you’ll need to use. Then, we’ll talk about when you should use each type of redirect, and teach you how to implement them in WordPress using two methods. Let’s get to it!

An Introduction to WordPress Redirects

First off, it’s important to know redirects aren’t a WordPress-exclusive feature. Tons of websites use them as a way to point traffic in the right direction. As for how they work, the process is simple. Imagine your visitors are walking down a hallway looking for your website and they run into a sign that tells them “Hey, the site you’re looking for moved to this new address, go check it out!”.

In practice, your visitors really don’t have a choice about being redirected since their browsers interpret that message and reroute them right away. However, that’s for the best since you’re probably redirecting them for a good reason.

There are three types of major redirects you can implement on your website. Let’s talk a bit about what they each do differently:

  1. 301 redirects. These tell your visitors your page moved to a new address permanently, so there’s no reason to check back later. On top of that, this type of redirect also passes on your search engine ranking (think about it as its popularity score) to the new page.
  2. 302 redirects. If 301 redirects signal a permanent move, 302s are more suited for temporary moves. In other words, if you think you’re going to remove your WordPress redirect at some point, this is the type you should use.
  3. Meta refresh. In both the previous cases, users are redirected before the page they were looking for begins to load. However, a meta refresh loads that page first and then redirects you to a new  URL. Needless to say, this process can be a waste of time, so it’s not something we recommend using under any circumstances.

With that in mind, you’ll probably only ever use 301 or 302 redirects in most situations. The former is usually the most popular type of redirect since it tells search engines they should replace your original page, so to speak. For all intents and purposes, a 301 redirect tells the world they should forget all about the original URL.

When to Use a WordPress Redirect

Now you know what redirects are and in which shapes they come. However, the question remains when it’s right to use them. Let’s discuss a few examples:

  1. If you change your website’s domain. Most people settle on a domain and just keep using it for as long as their website is around. However, you can change it if you feel you found a better option or you want to rebrand your website. In that case, you’ll want to reroute all traffic from your former domain to your new one using a 301 redirect, to keep your website’s search engine rankings.
  2. When you want to point multiple URLs to a single domain. Some large websites engage in the practice of buying tons of domains that are similar to their main ones. That way, they can target people who mistype them and prevent competitors from poaching them to confuse users. In these cases, you’ll want to redirect those URLs to your primary domain.
  3. To update your internal links. Most websites include links that point users towards some of their other pages within their body. When you change domains, for example, you’ll also need to implement redirects so your internal links don’t point towards your old URL.

To sum it up, the most common scenario where you’ll need to use a WordPress redirect has to do with changing your site’s domain. It’s not a common situation but if it happens, it’s important that you’re able to add one properly. Otherwise, you risk losing out on months if not years of hard Search Engine Optimization (SEO) work to build up your traffic.

How to Set Up a WordPress Redirect (In 2 Ways)

As is the case with most WordPress features, there are multiple ways you can implement a redirect for the platform. In this guide, we’re going to teach you how to do it using both a plugin and manually. Neither approach is inherently superior to the other, so choose whichever one you’re more comfortable with.

1. Use the WordPress Redirection Plugin

The Redirection plugin.

Using plugins, you can implement redirects without touching a line of code.

As you might expect from its name, the Redirection plugin is all about enabling you to add redirects to your website. On top of that, it also helps you keep track of 404 errors, which pop up when users try to access pages that don’t exist on your website.

If you’re looking for more advanced features, the plugin can even implement redirects on the fly, depending on a users login status. That way, you can redirect unregistered users away from private pages and more.

Finally, Redirection enables you to monitor the activity on each redirect you set up. That way, you’ll know when people stop visiting your old URLs and you can decide if you want to disable those redirects then.

To use the plugin, you’ll need to install it first. Be sure to back up your site before you proceed. Go to your dashboard and into the Plugins tab, then click on the Add New button at the top of the screen. On the next page, type Redirection within the search bar to the right and wait for the plugin to pop up among the results below. Once you see it, click on the Install Now button next to its name:

Installing the Redirection plugin.

After WordPress finishes installing your plugin, a new Activate button will appear next to it. Click on it and you’re ready to start implementing redirects on your website. Your first order of business is to go to the Tools > Redirection page on your dashboard. Inside, you’ll find a list including all your existing redirects, which should be empty:

A list of your existent redirects.

Below that, there’s a quick menu you can use to add a new WordPress redirect. All you have to do is type your Source URL and Target URL:

Adding a new redirect.

Before you click on the Add Redirect button, click on the gear icon next to it. Doing so will unfold a handful of advanced options, including the ability to choose which type of redirect to use:

Choosing a type of redirect.

Let’s take a minute to break down what some of these fields do before you go ahead and add a redirect. First off, enabling the Regex setting next to the Source URL field makes it so your redirect doesn’t just affect a single URL, but all its subdirectories as well. As an example, if you enabled it for examplewebsite.com/portfolio it’d also implement redirects for examplewebsite.com/portfolio/projectone and so on. With redirects, its best to choose each URL carefully, so keep that option disabled.

Moving on, you can also set a title for your redirect, so you can identify it more easily. The Match field enables you to implement advanced redirects depending on login statuses and more. In most cases, you’ll want to use the URL Only setting to avoid confusions. This way, your redirects won’t depend on any additional criteria to work:

Now, set the When matched settings to Redirect to URL and the HTTP code to whichever type of redirect you want to use. As you might recall, 301 is almost always the best choice except in very specific situations, which we discussed earlier in the guide.

Finally, you’ll see there’s a Group setting which enables you to add your redirect to either a Modified Posts or Redirections list. There are no practical repercussions to choosing either setting since groups are there just for organization purposes. In any case, you should choose the Redirections group, just to remain consistent. Here’s what your final settings should look like:

An example of what a new redirect should look like.

Now, click on the Add Redirect button and you’re good to go. The plugin will do all the necessary work in the background so when your visitors try to access an outdated URL, they’ll be sent to the correct one.

2. Modify Your .htaccess File

The .htaccess file is one of many WordPress core files that keep the platform working. This particular file governs how your website interacts with its server, which is the computer where it’s hosted.

Using your .htaccess file, you can implement a lot of advanced features. For example, if you’re a 000Webhost user, you’ll be glad to know we set up a custom .htaccess file for you, that should make your website load faster thanks to a few tweaks.

For this section, you’ll need to locate your .htaccess file and make a few changes to it to implement a redirect. To do it, we’re going to access your website via File Transfer Protocol (FTP) which is a technology that enables you to send and receive files from your server securely.

To use FTP, you’ll need a dedicated client. We’re partial to FileZilla because it’s easy to use and it’s an open source application that’s updated constantly. First off, download FileZilla and install it as you would any other program. Before you open it, though, you need to log into your 000Webhost control panel, which you can access from our home page. Inside, go to the Settings > General screen and look for the FTP Details section at the top. Here, you’ll find the credentials you need to access your website via FTP:

Your FTP details.

Keep this tab open now since you’ll need to copy your Host Name and Username in a minute. Go ahead and open FileZilla now and take a look at the top of the screen. There, you’ll see three empty fields called HostUsername, and Password:

Accessing your website via FTP.

Paste the values from the FTP Details section inside, use your 000Webhost password for the remaining field, then click on Quickconnect. FileZilla will access your website now and a couple of folders will pop up on the lower-right side of the screen:

Your server's folders.

Right now, we just care about the public_html folder, also known as your WordPress root directory. That’s where all the files and folders that make WordPress work reside, including .htaccess. Now, get ready to follow a few simple instructions:

  1. Enter the public_html folder.
  2. Locate the .htaccess file within and right-click on it.
  3. Click on the Download option.
  4. Right-click the .htaccess file once more now choose the View/Edit option.

This downloads a copy of your original .htaccess file to your computer, in case you ever need it. Then, you instructed FileZilla to open the file on your server using your local text editor. If everything went fine, the file should open:

Your htaccess file.

If you scroll down to the bottom of the file, you’ll find we already include a simple redirect within to make your life easier:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Don’t be intimidated by the small wall of code. What that snippet does is tell WordPress if someone tries to access a page or file that doesn’t exist on your website, they should be redirected to index.php (also known as your home page). To be fair, that’s a complex redirection, though. You can also add simpler ones, such as:

Redirect 301 /oldpost/ http://www.example.com/newpost/

This line of code instructs your server to redirect users trying to access /oldpost/ to a new URL. You’ll notice the oldpost section doesn’t include a full address, though. That’s because .htaccess already assumes it’s part of your website. In other words, when you type /oldpost/ before your new URL, WordPress sees it as  http://www.oldwebsite.com/oldpost/.

Keep in mind – that code only works if you want to redirect a specific page towards a new URL. If you want to redirect traffic from your entire website to a new domain, you’ll need to bring out bigger guns. Here’s what that would look like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
</IfModule>

Let’s take it from the top. This snippet tells WordPress if anyone tries to visit either example.com or www.example.com, they should be redirected towards you new domain (using the 301 format). In this case, it pays to specify your old URL both with and without the www prefix to ensure you don’t miss anything.

Now that you know how to add redirects to your .htaccess file, make sure any new code you put in there goes after your 000Webhost default settings, to avoid any issues. Just look for the # End WordPress line at the bottom of the file and place any code you want right before it. When you’re done, save the changes and close your text editor.

FileZilla will then ask you if you want to upload those changes to your server. Answer yes and you’re good to go. You’ve just implemented a WordPress redirect manually and it wasn’t that hard!

Conclusion

Redirects are an incredibly useful tool to have in your WordPress repertoire. They enable you to reroute traffic whenever you need to, so that users will find the content they want. Plus, using the right type of redirect can even pass on your SEO benefits to a new page, so your past efforts don’t go to waste.

As for how to implement a WordPress redirect – it can be a bit tricky. However, as in most cases, there’s a simple plugin-based approach and a manual one if you’re feeling up to it:

  1. Use the Redirection plugin.
  2. Modify your .htaccess file.

Do you have any questions about how to use WordPress redirects? Ask away in the comments section below!

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • php
  • my sql
  • intel
  • cloudlinux
  • nginx
  • cloudflare
  • wordpress