How to Redirect a URL in WordPress

Updating your WordPress site’s links can be a simple task in theory. However, if you get the process wrong, visitors could end up at a different, unintended page, or even worse — a broken link. This has plenty of impact on your search engine rankings, traffic numbers, and overall authority.

WordPress provides numerous easy-to-use plugins to redirect URLs for those who are unfamiliar with the process. This can help you to make sure you’re redirecting your URLs correctly.

In this tutorial, I’ll show you how to successfully redirect a WordPress URL, as well as the main types of URL redirects and when to use which one.

However, let’s first discuss what a URL redirect is and how it works!

What Is a URL Redirect

URL redirection (also referred to as URL forwarding) is a way to make a web page accessible under multiple URL addresses.

When the browser performs a URL redirect, a page with a different URL will be opened in place of the original one.

There are several ways to redirect a URL, and each has its own purposes — let’s see the three most common types.

1. 301 Redirects

For starters, a 301 redirect is permanent, taking place on both the browser and server side. It’s the most common and powerful redirect because it passes on the ‘link juice’ of an existing URL.

As a result, search engines are more likely to recognize and index this type of redirect, making this the preferred method in most situations.

2. 302 Redirects

In contrast, a 302 redirect is temporary and should only be used if you plan to move back to the original URL in the future.

For example, let’s say you are redesigning your website. While you are updating your website, you can use a 302 redirect to direct users to a different domain for a short time.

3. Meta Refresh

Web browsers also have a meta refresh functionality, which lets you redirect a URL to a new page without updating the server.

You can set the amount of time it takes for the redirect to happen, but by doing so, you also run the risk of making your visitors wait to get to their next page destination, thus potentially creating a poor user experience.

While there are other types of redirects you could use, these three are the ones you will see the most often — especially 301 redirects.

Why Use a URL Redirect

You may wonder why you would ever need to use a URL redirect on your own website.

We’ve touched on some reasons in the previous section, although there are others too, such as:

  • Preventing broken links – Broken links occur when the destination page has been moved or deleted or something such as a firewall is blocking access to your website. When users follow a broken link, they see a 404 error message in the browser. According to SEO specialist Bruce Clay, redirects are the most SEO-friendly way to fix broken links.
  • Linking multiple domains – If you manage multiple websites, you can use a redirect to link them to the same destination without affecting your SEO. Redirects help search engines see which page is the canonical source when multiple pages display the same information. This is also great for avoiding duplicate content penalties.
  • Protecting your privacy – Using the power of HTTPS, you can secure your website from hostile attacks such as phishing or malware distribution. Doing so requires you to redirect users and search engines to the HTTPS page, or resource with a server-side 301 HTTP redirect.

No matter what reason you have for redirecting users to a new page, it’s essential that you take the time to link it properly. An incorrect redirect can lead your visitors to the home page instead of the intended one, result in excessive redirects, and more.

How to Redirect a URL in WordPress (2 Methods)

There are two main techniques to redirect a URL in WordPress — you can either use a plugin or edit the .htaccess file.

Let’s start with a classic WordPress approach.

1. Use a WordPress Plugin

Redirect plugins can ensure that broken links lead to a relevant page on your site. This way, if a visitor happens to click a broken link, they will be redirected to the new page, which improves your website’s credibility and prevents your search rankings from dropping.

While there are plenty of great plugins to choose from, such as 301 Redirects, I recommend the Redirection plugin.

Redirection is remarkable for many reasons — not only has it been around for over a decade, but it also lets first-time users create and manage redirects without any prior knowledge of the Apache or Nginx web servers.

Redirection plugin

As Redirection provides complete support for regular expressions, you can enable redirect patterns to match any amount of URLs and redirect all of them to a target URL. You can also watch for changes in post or page permalinks, then automatically create a redirect to a new URL.

Once you’ve installed and activated the plugin, click the Tools > Redirection menu in your WordPress admin area, and run through the setup wizard steps.

The Redirection Onboarding Wizard.

When you’re done, head to the Redirects tab on the same admin page. This shows a list of current redirects. To add a fresh redirect, click the Add New button.

Adding a new redirection.

You’ll then see a bunch of fields pop up, including:

  • Source URL – This is the URL you’re redirecting from. For example, if you’re redirecting from https://myexample.com/old-post, your source URL will be /old-post.
  • Query Parameters – You can match parameters exactly (the default option) or ignore all parameters. With the latter, /old-post would match /my-old-post?query=1.
  • Target URL – This is the URL you’re redirecting to. For example, if you’re redirecting from https://myexample.com/old-post to https://myexample.com/new-post, your target URL will be /new-post.
  • Group – This lets you organize your redirects into categories.

Clicking on the gear icon will provide some additional options for matching redirects. Once these fields are filled in, click Add Redirect and the plugin will create the redirection rule.

2. Edit Your .htaccess File

The ‘hypertext access’ file — otherwise known as .htaccess — is a distributed server configuration file, which permits you to set server configurations for a particular directory. It’s used by the server when a request is made to a directory.

While it’s not as simple as installing a plugin, this powerful approach lets you set up pages, directories, and URL redirects. Before you begin, you’ll need the following skills and tools:

  • A suitable FTP client, such as Cyberduck or FileZilla
  • Access to your website’s server, usually named www or public_html
  • The requisite skills to use FTP

First, you need to fire up your FTP client and access your WordPress site’s root directory. Scan the directory for the .htaccess file, then open it using your standard text editor.

Once .htaccess is open, place your cursor at the end of the file and enter the redirection rules depending on your needs.

To redirect a single page to another page, add the following rule:

Redirect 301 /old-page.html http://www.example.com/new-page.html

To redirect an entire domain name to another domain, enter the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www.)oldsite.com$ [NC]
RewriteRule ^ http://newsite.com%{REQUEST_URI} [L,R=301]

This snippet sends visitors from a page at the old address to the same page at the new one — for example, from www.oldsite.com/post to www.newsite.com/post. Don’t forget to change the placeholders to your own domains and pages.

When you’re done, save your changes, and test out your new redirects!

Conclusion

In this tutorial, I showed you how to redirect a URL in WordPress using two methods, respectively:

  • Install a redirect plugin.
  • Edit your .htaccess file.

Redirecting URLs is not an everyday task but still fairly common. As such, getting it right means users will have a seamless experience on your site and your search engine rankings won’t be dropping for things like broken links or duplicate content.

Do you have any further questions relating to URL redirection? Feel free to reach out in the comments section below!

Leave a Reply

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