The WordPress redirect functionality built into the core platform is designed to catch incorrect URLs. That’s to say: when a wrong URL is requested, WordPress tries to locate the correct URL and will redirect the visitor if it does.
Further reading:
How to Fix 404 Errors in WordPress After Changing Permalinks
The Many Uses to Which You Can Put Your WordPress Website
Top 5 Security Issues with WordPress and How to Fix Them
In this post, we’ll explain the importance of WordPress redirects and how they influence page speed and, of course, SEO. We’ll also discuss how you can minimize redirects in WordPress and guide you through the various solutions you can use to set them up.
- An Introduction to WordPress Redirects
- How WordPress Redirects Impact Page Loading Speed
- How WordPress Redirects Affect Your Site’s SEO
- To Redirect or Not to Redirect?
- How to Minimize Redirects in WordPress
- Setting Up Redirects on the Server-Level
- Creating a WordPress Redirect With a Plugin
- Other WordPress Redirect Plugins
Introduction to WordPress Redirects
WordPress core comes with redirect functionality that is intended to help catch and correct incorrect URLs. If someone requests an incorrect URL, WordPress attempts to locate the correct one and then redirects the visitor if it was successful.
Let’s say you have a page that resides at “http://www.example.com/parent/page”. If you type “http://example.com/page” into your browser, typically, WordPress is smart enough to automatically locate the correct page to redirect you to.
Unfortunately, it’s not always that simple. If you set up your website to resolve using HTTPS (so as to force all traffic to be redirected from the HTTP to HTTPS prefixed URL), the redirection process becomes more complex.
For example, imagine that a visitor attempts to access the web page “https://www.example.com/parent/page” by typing “http://example.com/page” into the address bar. The process would unfold as follows:
- First, the visitor is redirected from HTTP to HTTPS.
- Second, the visitor is redirected when “www” is added to the URL.
- Third, the visitor is redirected to the URL formulation that includes the parent page in the path.
- Finally, the server begins to send the website’s files and resources to the visitor’s browser.
You might be thinking: “That’s great! I can butcher a link and the visitor will still end up where they’re supposed to be.” In a sense, you’d be right to think that. WordPress is very good at figuring out where URLs are supposed to resolve, and this means that mistyped URLs will often resolve properly.
However, all of this auto-redirection also have a downside. When changes to your URL structures occur, you'll need to follow these redirect best practices or risk impacting your SEO and UX.
Further reading:
How to modify search features of your WordPress website
7 Security Tips for a WordPress Website
Basic Guide to WordPress Security
How WordPress Redirects Impact Page Loading Speed
Once you realize how resilient WordPress is, it’s easy to get tricked into neglecting URL formulation. This is particularly dangerous if you manually type out the URLs in inline links and custom menus.
Visitors still end up at the correct URL! While that’s true in theory, what you’re overlooking is the impact redirects have on page loading speed.
Let’s take a look at a Pingdom page speed result for a WordPress website. This test is based on accessing a page using a properly-formulated URL, in order to avoid any redirects:
That’s not bad at all. If we look at the file requests, we see that there are no redirects happening when the site is requested:
So what happens if we mess up that URL and run the test again?
That adds almost 100 milliseconds to the page loading time.
Now there is a redirect added to the front of the URL. Following the redirects, the page loads as normal. So we can attribute the slower page speed to the redirect happening when the incorrect URL is fed into the test.
The bottom line is that redirects hurt web page loading speed. The difference can be significant and measurable.
Further reading:
How to Remove the "Powered by WordPress" Footer Link
How to Secure a WordPress Website
How WordPress Redirects Affect Your Site’s SEO
If you have a basic understanding of SEO, you probably know the important role links play in it. If a URL links to a page that no longer exists, or was transferred to another link that was moved, your visitors may encounter a 404 page error:
In addition to poor user experience, a 404 ‘page not found’ error can also hurt you from an SEO standpoint. These 404 errors are the result of broken links, which affect search engines’ ability to crawl your website and locate its pages.
This signals to search engines that users not only are able to find what they’re looking for but that you have a poor and outdated site architecture as well.
Therefore, it’s essential to set up redirects for pages with changed URLs. If you’re moving your site to a new domain, configuring WordPress redirects can make it so that search engine crawlers are still able to index the new site URLs, while simultaneously ridding the old ones from the index.
Redirects can also help ensure that link juice will be passed from your old domain to your new one and within your own pages. However, it’s important to note that only certain HTTP redirect codes will pass on your ranking in search engines.
The Various Types of URL Redirects
As a WordPress user, the most common type of redirect you’ll be dealing with (and the best for SEO purposes) is a 301 redirect. This is used for content that has been permanently moved.
301 redirects tell search engines the page you want to send visitors to has changed or moved and pass between 90-99% of link juice. In most cases,
To Redirect or Not to Redirect?
Redirects exist for a reason. They allow you to send visitors from outdated content and nonexistent URLs to updated content. We already covered the nonexistent URLs angle to a degree. WordPress does some of that all on its own.
However, WordPress won’t catch everything, and there are times when manual redirect rules are needed.
For example, let’s say you wrote an article titled “What’s Brand New in WordPress” back when WordPress 3.0 was released. It was a great post back, but searchers looking for “what’s new in WordPress” today want newer information. You want to keep those readers happy, so you write a new post about the features included in an upcoming version of WordPress.
In this scenario, a redirect from the old post to the new post is perfectly acceptable and appropriate. Additionally, in this case, a redirect is good SEO practice. The link juice attributed to the old post would be passed to your new post instead, giving it instant weight in search engines.
There are several scenarios where redirects are appropriate, including:
- You’ve posted updated content and want to steer visitors away from the older version.
- You’ve overhauled a website’s permalink structure and need to redirect old URLs to their new structure.
- You’re updating a published page or post and want to temporarily redirect traffic to a different post or page while you work on the update.
When Not to Redirect
In all of the scenarios above, redirects are necessary to send visitors from outdated content and broken URLs to updated content. They’re also handy as a temporary measure while a specific bit of content is updated.
So, when is it not appropriate to use a WordPress redirect? For example, if you’ve built a custom menu using URLs that don’t include “www”, but your site URL does resolve with the “www” subdomain at the front of the URL, you’re making a mistake.
Using redirects in that scenario is not appropriate and hurts the speed and SEO of your site.
How to Minimize Redirects in WordPress
If you’re sold on the idea of minimizing redirects in WordPress, there are two important things you need to do.
1. Never Create Unnecessary Redirects
The first thing to remember is to never intentionally create unnecessary redirects. For example, you shouldn’t create redirects when building internal links and menus.
If you’ve gotten into the habit of typing URLs lazily, it’s best to rethink the way you’re working. Instead, when you create a URL make sure that you:
- Use the proper protocol prefix (HTTP or HTTPS).
- Include or exclude the “www” subdomain as appropriate.
- Don’t use post and page IDs in links.
- Include the entire path to the page or post.
The redirection power built into WordPress is supposed to be a fallback, in case you accidentally create a bad URL. It’s not a very reliable fix for lazy URL writing in general.
2. Make Sure Your Top-Level Domain (TLD) Resolves With No More Than One Redirection
The second thing you can do to minimize the occurrence of WordPress redirects is to make sure your Top-Level Domain (TLD) resolves with no more than one redirection. Your goal is to make sure that the correct URL is reached through one redirection or less, no matter what combination of protocol prefix and subdomain a visitor throws in front of the TLD.
Let’s look at an example. All of the following URLs should resolve to the TLD with no more than one redirection and one of these should resolve with no redirects:
- http://example.com
- http://www.example.com
- https://example.com
- https://www.example.com
If you do find that some combinations either fail to resolve (return a 404 server status code) or require more than one redirection to resolve, then it’s time to get to work.
Setting Up Redirects on the Server-Level
One method you can take for setting up a WordPress redirect is to add one or more redirection rules to your server. This will ensure that visitors land at the proper formulation of your site’s URL as quickly as possible.
The basic goal you’re trying to accomplish is to create redirect rules that target any URL formulations requiring more than one redirection. You want to force those URLs to resolve directly to the properly-formulated URL.
For example, if the URL “http://example.com” requires two redirects to get to “https://www.example.com”, you can create a manual redirection that makes that happen in one step (rather than two).
Redirect Rules in Apache
If your site is hosted on a standard LAMP stack, you will need to add URL rewriting rules to your site’s .htaccess file. Setting up a WordPress redirect through a web server configuration file is a technical process and can be complicated.
Therefore, only use this method if you’re comfortable with editing your .htaccess file. Even if you are, it’s still a good idea to create a backup of the file first.
Then, the first step is to connect to your WordPress installation using an FTP client, or through your hosting cPanel’s File Manager. You can locate the .htaccess file in the root directory of your WordPress site.
To set up a 301 redirect, you’ll need to specify the old and new URL locations with a syntax structure that looks like this:
Redirect 301 "old-page" "new-page"
If you want to redirect all of your site’s traffic from HTTP to HTTPS, you can use the following:
Keep in mind that before doing this, it’s important to make sure you have your SSL certificate properly configured on the new WordPress site.
Redirect Rules in Nginx
If you’re using a more advanced hosting configuration, there’s a good chance it’s powered by Nginx rather than Apache. In that case, things aren’t quite as simple.
Redirection configuration will vary from one host to the next and you’ll want to get in touch with your host’s support to fix the redirection issue.
However, if you feel confident in your abilities, you can create a redirect in Nginx by creating a server block for the content you want to redirect, using the following code:
In the above directive, “return” is used for a URL substitution. It returns the status code specified in the redirection URL. The “$scheme” variable uses the scheme from the original http/https request and returns the 301 redirect code with the new URL.
Creating a WordPress Redirect With a Plugin
If your host doesn’t have a redirect rules feature, you might have to use a WordPress plugin. There are many redirection plugins available and Redirection is one of the most popular ones you can use:
This plugin is very easy to use and can be set up to create redirects using WordPress code, .htaccess on Apache servers, or Nginx server redirects. Plus, it’s free.
Here’s how to get started with the Redirection plugin.
After you download it from the Plugin Directory, you can locate it by going to Tools > Redirection:
This will bring you to a welcome page. Click on the Start Setup button, then follow the series of prompts. Once it’s done, you can begin using it.
How to Manually Add a New Redirection
You can manually add a new redirection by clicking on the Add new button, then inputting the source and target URLs into the respective form fields and clicking on the Add Redirect button:
This approach is only recommended if you have just a few URLs to redirect. If you’re dealing with an entire site’s worth, you’re encouraged to save time by using the plugin’s URL import feature.
Import/Export Redirects
Another helpful way you can use this plugin is to import and export redirects. For example, you can export old URLs from your website, then use the plugin on a new site to import the list.
To do this, install and activate the Redirection plugin on your old website. Next, from your WordPress admin dashboard and go to Tools > Redirection > Import/Export.
At the bottom of the screen, under Export, you can export everything to a CSV, Apache .htaccess, Nginx rewrite rules, or Redirection JSON file:
Then, with the plugin installed on your new site, you can go to the same screen to import the file:
Click on the Add File button and select the file. Once it’s uploaded, you can find the new URLs listed under the Redirects tab.
Other WordPress Redirect Plugins
This is not the only WordPress redirect plugin you can use. 301 Redirects is another popular plugin that will be preferred by users looking for a shopping list of configuration options. With over 80,000 active installs, it’s certainly been well tested. It is easy to learn, has a well-designed interface, and can be used to manually create 301 and 302 redirects.
One particularly nice feature is a dropdown menu for selecting pages, posts, media pages, and archive pages as the redirection target. This ensures that manually-created redirection rules resolve without any issues. You can also retain query strings across redirects.
Summary
Plain and simple: if implemented poorly, WordPress redirects can slow down your site. That’s why it’s worth taking the time to minimize the number of redirects.
You can do this by avoiding creating unnecessary redirects and making sure your TLD resolves with no more than one redirection.
However, there are times when it’s appropriate to intentionally create and use redirection. When this is the case, there are two ways to go about it:
- You can set up redirects at the server-level. Some hosting providers offer features that can help, such as the redirection rules tool
- Use a WordPress plugin such as Redirection to manually add a few redirects or import a list of URL redirects.
By limiting the use of redirection to necessary instances and using WordPress redirect best practices, you help ensure that your visitors have the fastest experience possible and your conversion rates won’t decline.
Plus, you won’t have to worry about hurting your SEO and losing your rankings!