When you redesign your site or update old content, you may change your URL structure. If you do not follow WordPress redirection best practices, you may have a negative impact on user experience (UX) and search engine optimization (SEO).
The WordPress redirection feature built into the core platform is designed to capture incorrect URL. That is: when the wrong URL is requested, the WordPress tries to find the correct URL, and if so, redirects the visitor.
In this article, we will explain the importance of WordPress redirects and how they affect page speed, as well as SEO. We will also discuss how to minimize redirects in WordPress and guide you through the various solutions that can be used to set them up.
- Introduction to WordPress redirection
- How WordPress redirection affects page loading speed
- How WordPress redirection affects the SEO of your website
- Redirect or not redirect?
- How to minimize redirection in WordPress
- Set redirection at the server level
- Use plug-ins to create WordPress redirects
- Other WordPress redirect plug-ins
Introduction to WordPress redirection
The WordPress core has redirection capabilities designed to help capture and correct incorrect URL. If someone requests the wrong URL,WordPress, it tries to find the correct URL and redirects the visitor if it succeeds.
Suppose you have a page at “http://www.example.com/parent/page”. If you type “http://example.com/page” in your browser, WordPress is usually smart enough to automatically navigate to the correct page to redirect you to.
Unfortunately, things are not always that simple. If you set up the site to use HTTPS resolution (to force all traffic to redirect from the HTTP to the HTTPS prefix URL), the redirection process becomes more complex.
For example, suppose a visitor tries to access the web page “https://www.example.com/parent/page” by typing “http://example.com/page” in the address bar. The process will unfold as follows:
- First, visitors are redirected from HTTP to HTTPS.
- Second, when “www” is added to URL, visitors are redirected.
- Third, visitors are redirected to the URL formula that contains the parent page in the path.
- Finally, the server starts sending files and resources from the site to the visitor’s browser.
You might think, “Great!” I can delete a link and visitors will still get to where they are supposed to be. ” In a sense, you are right to think so. WordPress is very good at determining where the URL should be parsed, which means that the incorrectly typed URL is usually parsed correctly.
However, there is a drawback to all these automatic redirects.
How WordPress redirection affects page loading speed
Once you realize the resilience of WordPress, it’s easy to be fooled into ignoring the URL formula. This is especially dangerous if you manually enter URL from inline links and custom menus.
It’s not a big deal, is it? Visitors will still access the correct URL! While this is correct in theory, what you ignore is the impact of redirection on page loading speed.
Let’s take a look at the Pingdom page speed results of the WordPress website. This test is based on accessing the page using a well-formed URL to avoid any redirection:
Pingdom test results with correct format URL
It’s not bad at all. If we look at the file request, we will see that the redirection did not occur when the site was requested:
File request from Pingdom
So what happens if we mess up that URL and run the test again?
Pingdom test results with error URL
This increases the page load time by nearly 100 milliseconds. Although this doesn’t seem like a big deal, because the site is fast enough, let’s take a look at the file request and see what happens:
Incorrect URL file request
Now a redirect is added in front of the URL. After redirection, the page loads normally. Therefore, we can attribute the slower page speed to the redirection that occurs when incorrect URL input is tested.
The bottom line is that redirection can damage the loading speed of a web page. The differences may be significant and measurable.
How WordPress redirection affects the SEO of your website
If you have a basic understanding of SEO, you probably know the important role links play in it. If a URL is linked to a page that no longer exists, or is transferred to another moved link, your visitors may encounter a 404 page error:
404 error page in Chrome
In addition to a poor user experience, the 404 “page not found” error can also hurt you from a SEO perspective. These 404 errors are the result of broken links, which can affect the search engine’s ability to crawl your site and locate its pages.
This signals to search engines that not only can users find what they are looking for, but your site is poorly structured and outdated.
Therefore, you must set up redirects for pages that have been changed by URL. If you want to move the site to a new domain, configure WordPress redirection so that the search engine crawler can still index the new site URL while removing the old site from the index.
Redirection can also help ensure that link juice is passed from your old domain to your new domain as well as to your own pages. However, it is important to note that only some HTTP redirection code will pass on your ranking in the search engine.
Various types of URL redirection
As a WordPress user, the most common type of redirection you will deal with (and best suited for SEO purposes) is 301redirection. This is for content that has been permanently moved.
The 301 redirect tells the search engine that the page to which you want to send visitors has been changed or moved and passed between 90-99% of the link weights. In most cases, this type of redirection will cause the search engine to pass most of the link weights (or page permissions) to new or updated pages.
Other types of server-side redirects include:
- three hundred and two。 This temporary redirect informs the search engine that the page is moving, but not permanent. It does not pass the link juice like the 301 redirect.
- 303. This type of temporary redirection is used to prevent pages that are storing data from being refreshed or bookmarked (payment forms, login pages, and so on). In this way, the user cannot resubmit the form after clicking the back button in the browser. These redirects do not affect SEO.
- 307. 307 redirection is similar to 303 redirection because it should only be used for temporarily moved pages. However, 302 redirection is usually the preferred method.
- three hundred and eight。 308 redirects are permanent redirects, so it passes link juice and page permissions. However, as with previous redirects, its impact on SEO is unknown. In most cases, it is best to use 301.
As we said, all of the above is considered server-side redirection.
There are also client-side redirects, which are triggered when the user’s browser handles forwarding or redirection. However, these are unreliable and should be avoided.
Server-side redirection is the best way to ensure that search engines can quickly understand redirection and transfer your SEO weights appropriately.
Redirect or not redirect?
There is a reason for redirection. They allow you to send visitors from outdated content and non-existent URL to updated content. To some extent, we have covered the URL angle that does not exist. WordPress did some of the work himself.
However, WordPress does not capture everything and sometimes requires manual redirection of rules.
For example, suppose you wrote an article entitled “New Features in WordPress” when WordPress 3.0 was released. This is a great post from 2010, but searchers looking for “New Features in WordPress” in 2022 want updated information. You want to satisfy these readers, so you wrote a new article about the features included in the upcoming WordPress release.
In this case, it is perfectly acceptable and appropriate to redirect from the old post to the new post. In addition, in this case, redirection is a good SEO practice. The link weight attributed to the old article will be passed to your new article to get the weight immediately in the search engine.
There are several scenarios suitable for redirection, including:
- You have released the updated content and want to guide visitors away from the old version.
- You have thoroughly examined the fixed link structure of the site and need to redirect the old URL to the new structure.
- You are updating a published page or article and want to temporarily redirect traffic to a different article or page when you do the update.
When not to redirect
In all of the above scenarios, redirection is necessary to direct visitors from outdated content and corrupted URL to newer content. They are also convenient as temporary measures when updating specific content.
So, when is it not appropriate to use WordPress redirects? For example, if you build a custom menu using URL that does not contain “www”, but your site URL does use the “www” subdomain resolution in front of URL, then you are making a mistake.
Using redirects in this case is inappropriate and can damage the speed and SEO of your site.
How to minimize redirection in WordPress
If you are satisfied with the idea of minimizing redirection in WordPress, there are two important things you need to do.
1. Never create unnecessary redirects
The first thing to remember is never to deliberately create unnecessary redirects. For example, you should not create redirects when building internal links and menus.
If you get into the habit of typing URL lazily, it’s best to rethink the way you work. Instead, when you create a URL, make sure that you:
- Use the correct protocol prefix (HTTP or HTTPS).
- Include or exclude “www” subdomains as appropriate.
- Do not use articles and page ID in links.
- Includes the entire path to the page or post.
WordPress’s built-in redirection should be a backup function in case you accidentally create the wrong URL. In general, this is not a very reliable fix for lazy URL writing.
two。 Make sure that your top-level domain (TLD) can be resolved with only one redirect
To minimize the occurrence of WordPress redirects, the second thing you can do is to ensure that your top-level domain (TLD) parses with no more than one redirect. Your goal is to ensure that the correct URL is reached with one or fewer redirects, no matter what combination of protocol prefixes and subdomains the visitor throws before TLD.
Let’s look at an example. All of the following URL should resolve to TLD and not more than one redirect, one of the URL should resolve to no redirect:
- http://example.com
- http://www.example.com
- https://example.com
- https://www.example.com
If you are not sure how many redirects are required to parse the site URL using different combinations of protocol prefixes and subdomains, you can check using Patrick Sexton’s redirect mapper:
Redirect Mapper tool
The following is an example of how to use this redirect mapper to easily discover redirects that are not set correctly:
The redirection setting is incorrect
You can see that repeated redirects have occurred in the “www” version of the domain. Instead, this is an example of setting the redirection correctly:
The redirection setting is correct
As you can see, both “www” and “no www” have been redirected only once.
If you do find that some of these combinations cannot be resolved (returning a 404 server status code) or require multiple redirects to resolve, it’s time to get started.
Set redirection at the server level
One way to set up WordPress redirection is to add one or more redirection rules to the server. This will ensure that visitors log in to your site’s URL in the right way as soon as possible.
The basic goal you are trying to accomplish is to create redirection rules for any URL formula that requires multiple redirects. You want to force these URL to be parsed directly into a well-formed URL.
For example, if URL “http://example.com” requires two redirects to reach “https://www.example.com”, you can create a manual redirect that is done in one step (instead of two).
Redirection rules in Apache
If your site is hosted on a standard LAMP stack, you need to add URL rewriting rules to the. htaccess file of your site. Setting up WordPress redirects through Web server profiles is a technical process and can be complex.
Therefore, use this method only if you are satisfied with editing the .htaccess file. Even if you are, it’s still a good idea to create a backup of the files first.
Then, the first step is to connect to your cPanel installation using the WordPress client or through the file manager that hosts WordPress. You can find the .htaccess file in the root directory of the WordPress site.
To set up the 301 redirection, you need to specify the new and old URL locations using the syntax structure shown below:
Redirect 301 "old-page" "new-page"
If you want to redirect all traffic for your site from HTTP to HTTPS, you can use the following command:
RewriteEngine On RewriteCond !{HTTPS} off RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Keep in mind that before you do this, make sure that you have the SSL certificate configured correctly on the new WordPress site.
Redirection rules in Nginx
If you are using a more advanced managed configuration, it is likely to be supported by Nginx rather than Apache. In that case, things are not that simple.
The redirect configuration varies from host to host, and you need to contact host support to resolve the redirection issue.
However, if you are confident in your abilities, you can use the following code to create a redirect in Nginx by creating a server block for the content you want to redirect:
server { listen 80; server_name domain1.com; return 301 $scheme://domain2.com$request_uri; }
In the above instructions, “return” is used for URL substitution. It returns the status code specified in the redirect URL. The “$scheme” variable uses the scheme from the original http/https request and returns the 301 redirection code with the new URL.
Another option is to use:
rewrite ^/$ http://www.domain2.com permanent; rewrite ^/(.*)$ http://www.domain2.com/$1 permanent;
This can be used to create permanent redirects. For more details, you can check out F5 Network’s guide on creating Nginx rewriting rules.
However, there are also WordPress plug-ins that you can use to redirect WordPress sites.
Before taking a closer look at redirecting plug-ins, it is important to note that using them can sometimes cause performance problems. Most of them use wp_redirect functions, which require additional code execution and resources.
Use plug-ins to create WordPress redirects
If your host does not have the redirection rules feature, you may have to use the WordPress plug-in. There are many redirect plug-ins available, and Redirection is one of the most popular plug-ins you can use:
WordPress plug-in-Redirection
This plug-in is very easy to use and can be set up to create redirects using WordPress code, .htaccess on the Apache server, or Nginx server redirection. Besides, it’s free.
Here is how to start using the redirect plug-in.
After downloading from the plug-in directory, you can find it through the tool & gt; Redirection:
WordPress plug-in Redirection Welcome Page
This will take you to the welcome page. Click the “Start Setup” button and follow a series of prompts. When you’re done, you can start using it.
How to manually add a new redirect
You can manually add a new redirect by clicking the “Add New” button, then enter the source URL and destination URL into the appropriate form fields, and then click the “Add Redirect” button:
Add new redirection interface in the Redirection plug-in
This method is recommended only if you have only a few URL to redirect. If you are dealing with the value of the entire site, we encourage you to use the plug-in’s URL import feature to save time.
Import / Export Redirection
Another useful way you can use this plug-in is to import and export redirects. For example, you can export the old URL from your Web site, and then use the plug-in to import the list on the new site.
To do this, install and activate the redirect plug-in on the old website. Next, go from your WordPress management dashboard to the tool & gt; Redirection & gt; Import/Export.
Under Export at the bottom of the screen, you can export everything to CSV, Apache .htaccess, Nginx rewriting rules, or redirect JSON files:
The Export section of the WordPress plug-in Redirection
Then, after installing the plug-in on your new site, you can go to the same screen to import the file:
Import / export interface in the Redirection plug-in
Click the Add File button and select the file. After uploading, you can find the new URL listed under the Redirects tab.
Other WordPress redirect plug-ins
This is not the only WordPress redirect plug-in you can use. Redirects is another popular plug-in that users will choose when looking for a shopping list of configuration options. With more than 80000 active installations, it must have been well tested. It is easy to learn, has a well-designed interface and can be used to manually create 301 and 302 redirects.
A particularly good feature is to select pages, articles, media pages, and archive pages as drop-down menus for redirection. This ensures that manually created redirection rules can be resolved without a problem. You can also retain query strings across redirects.
Summary
Simple and straightforward: if not implemented properly, WordPress redirection may slow down your site. This is why it is worth taking the time to minimize the number of redirects.
You can do this by avoiding creating unnecessary redirects and ensuring that your TLD parsing does not exceed one redirect.
However, sometimes it is appropriate to deliberately create and use redirects. In this case, there are two ways to solve the problem:
- You can set redirection at the server level.
- Use the WordPress plug-in (for example, Redirection) to manually add some redirects or import URL redirect lists.
By limiting the use of redirects to the necessary instances and using WordPress redirection best practices, you can help ensure that visitors get the experience as quickly as possible and that your conversion rate does not decline.
In addition, you don’t have to worry about damaging your SEO and losing your rankings!