[rank_math_breadcrumb]

How To Redirect a URL in WordPress

Understanding URL Redirection

Before diving into the methods, it’s important to have a solid understanding of what URL redirection is and why it’s important.

To put it simply, URL redirection is a technique used to forward one URL to another. There are several types of redirects, each serving different purposes:

  • 301 Redirect: This is a permanent redirect, indicating that the original URL has been moved to a new location. It’s the most SEO-friendly type of redirect as it passes the authority of the link from the old URL to the new one.
  • 302 Redirect: This is a temporary redirect, suggesting that the original URL still exists with content, but users are being directed elsewhere. It doesn’t pass the link equity to the new URL and should almost never be used for SEO purposes.
  • 307 Redirect: Another temporary redirect similar to 302, but it preserves the request method used.
  • Meta Refresh: This type of redirect is set at the page level rather than the server level. It often includes a delay and is less SEO-friendly.

Why Redirect URLs?

So what exactly is the purpose of redirecting URLs? There are a few situations in which URL redirection can be handy, such as:

  • When you’re changing domain names: If you ever change your website to a new domain name, then you’ll want to redirect your old domain URL to the new one so that your users don’t get an error. Creating a WordPress 404 redirect means that everyone who remembers the old URL or has it bookmarked will automatically be redirected to the new website.
  • If you need to reorganise your content: Sometimes it’s beneficial to restructure your website content by changing the permalink structure or merging pages. Redirecting URLs helps to ensure that visitors and search engines can still find the content even after you’ve reorganised everything.
  • To fix broken links: It’s also important to use URL redirects to fix broken or dead links to relevant content. It can be used to automatically forward users from an old or incorrect URL to a newer correct one, ensuring that they still reach the desired content even if the original link isn’t valid anymore.
  • Using temporary pages: Sometimes, it’s a good idea to create temporary pages for the purposes of campaigns or promotional events. Once they end, it’s a good idea to redirect those URLs to your homepage.
  • Creating nice-looking links: Redirection can be used to create shorter, more memorable URLs for marketing campaigns or printed materials, making it easier for users to access specific content.
  • Moving from HTTP to HTTPS: Redirecting all HTTP URLs to their HTTPS counterparts ensures that all traffic to your site is secure, protecting user data and boosting SEO rankings.
  • To force WWW or non-WWW links: Standardising your URLs to either always include or exclude “www” helps avoid duplicate content issues and provides a consistent user experience.

Redirecting URLs is essential for managing domain changes, reorganising content, fixing broken links, using temporary pages, creating nice-looking links, moving from HTTP to HTTPS, and standardising WWW or non-WWW links. These practices lead to a seamless user experience, maintain SEO rankings, and improve site security and performance.

How to Redirect URLs in WordPress

There are several different methods to create a WordPress redirect page, such as the following:

Using Plugins

Plugins offer a user-friendly way to manage redirects without needing any technical knowledge. It’s usually the go-to method to add a URL redirect with minimal hassle. Here are some popular redirect plugins for WordPress:

Redirection Plugin

The Redirection plugin is one of the most popular and convenient tools available. It provides a straightforward interface to manage 301 redirects and even helps you track 404 errors.

Yoast SEO Premium

If you’re using Yoast SEO Premium, then you already have access to a built-in redirection manager.

Simple 301 Redirects


This is another simple and easy-to-use URL redirection plugin that can be used to create simple 301 redirects. The interface is clean and simple to understand and also has wildcard support to help you redirect all files within a directory.

Manual Methods

If you prefer not to use or install plugins, then there are a couple of manual methods that you can use to achieve the same results. These often require editing some files manually, so you should be cautious with these methods. We only suggest trying this if the plugin method doesn’t work, or if you’d prefer to learn a more powerful manual method that can teach you about how your website works behind the scenes.

Editing the .htaccess File

The .htaccess file is a configuration file for your website that is used by Apache servers to manage different settings including redirects.

First, you’ll need to locate your .htaccess file. This will likely involve using an FTP client or your web host’s file manager to locate and open the file.

Next, make absolutely sure to backup your .htaccess file before you make any changes. This is to ensure you have a safe and working copy of the file to revert to if something goes wrong or if you make a mistake.

Now you can add redirection rules to the file. You can add the following line to the file:

“Redirect 301 /old-url https://yourwebsite.com/new-url”

Simply replace “/old-url” with the path of the old URL and “https://yourwebsite.com/new-url” with the full new URL.

Now you can save the file and upload it if needed to make the changes. You’ll want to upload the modified .htaccess file and keep a backup locally and on the server just in case.

Most WordPress hosts use Apache, but there are some providers that use other servers such as Nginx. It’s important to note that this method only works for WordPress websites hosted using Apache, as it’s the only one that supports .htaccess files. If you can’t find the .htaccess file then it’s likely that your WordPress host isn’t using Apache. It’s worth reaching out to the host to ask them how to proceed, as they might have their own custom-built redirection tools.

Using the wp_redirect Function

The wp_redirect function is a WordPress-specific function that allows for quick and easy redirection within your theme or plugin files.

Start by accessing the appropriate file. This is going to depend on where you want to implement the redirect. For example, it might be the theme’s template files or a custom plugin file.

Next, add the redirect code by using the “wp_redirect(‘https://yourwebsite.com/new-url’, 301);” command. Make sure to add the “exit;” line afterward. It should look like this:

wp_redirect(‘https://yourwebsite.com/new-url’, 301);

exit;

Make sure to replace the “https://yourwebsite.com/new-url” with your own URL that you want to redirect to.

Now save the changes after adding the code and it should now redirect to another page that you’ve set.

Server-Level Redirects

A server-level redirect is a method of URL redirection managed directly on the web server, such as through .htaccess for Apache. This approach ensures faster and more reliable redirects by processing them before any website content is even loaded, enhancing both user experience and SEO.

Why Server-Level Redirects?

Server-level redirects are processed before any content is served, making them faster and more reliable compared to client-side redirects. This method is ideal for large-scale changes, such as domain migrations or site restructures since it reduces the risk of errors and improves site performance.

Additionally, server-level redirects help maintain SEO rankings by passing link equity from old URLs to new ones, ensuring that the entirety of your old site retains its search engine visibility and authority.

Here are some of the most common reasons for using server-level redirects:

  • Domain changes
  • Switching from HTTP to HTTPS
  • Standardising URLs (WWW to non-WWW or vice versa)
  • Handling site restructures
  • Fixing broken links

Make absolutely sure to back up your .htaccess file before you make any changes to ensure you have a clean and working file should you make a mistake. Remember that you can also use plugins if you don’t like the idea of manually editing a file.

Redirecting HTTP To HTTPS

Redirecting HTTP to HTTPS ensures that all traffic to your website is secure. For Apache servers, add the following to your .htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You can also use a plugin such as Really Simple SSL or WP Force SSL.

Redirecting WWW To Non-WWW (or Vice Versa)

To redirect WWW to non-WWW in Apache, add the following to your .htaccess file:

WWW to non-WWW:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.yourwebsite.com [NC]

RewriteRule ^(.*)$ https://yourwebsite.com/$1 [L,R=301]

Non-WWW to WWW

RewriteEngine On

RewriteCond%{HTTP_HOST} ^yourwebsite.com [NC]

RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [L,R=301,NC]

Make sure to replace “yourwebsite.com” with your website domain.

Redirecting an Entire Domain

If you’re looking to redirect an entire domain after switching to a new one, then you can add the following to your old .htaccess file. Make sure you’re only editing the one on your old website and not the new one.

#Options +FollowSymLinks

RewriteEngine on

RewriteRule (.*) https://yournewwebsite.com/$1 [R=301,L]

Use Plugins or Manual Methods?

Using plugins for URL redirection in WordPress is ideal for those seeking a user-friendly and quick setup, especially for non-technical users who just want to quickly redirect a URL. Plugins often provide additional features like 404 error tracking and bulk redirects too, making them great for multiple different purposes.

On the other hand, manual methods are suited for advanced users who need greater control and optimization. Editing the .htaccess file or using PHP functions allows for more customisation and potentially more efficient redirects.

We suggest that you use plugins when ease of use and comprehensive management are priorities. Choose manual methods for fine-tuned control, performance considerations, or when specific server configurations are necessary.

Best Practices for URL Redirection

Adding URL redirects can have a huge impact on the performance and SEO of your website. So here are some of the best practices for effective URL redirection.

Use 301 Redirects for Permanent Moves

Always use 301 redirects for permanent URL changes to pass link equity to the new URL. A 301 redirect tells search engines that the old URL has moved permanently to a new location, so this ensures that the SEO value of the original URL is transferred to the new one. This helps a lot in maintaining your site’s search engine rankings and prevents users from encountering broken links.

Update Internal Links

After setting up redirects, make sure you update internal links on your site to point directly to the new URLs. This prevents unnecessary redirects which can slow down page load times and degrade the user experience, ultimately leading to a lower SEO score. By updating internal links, you also make sure that your site’s navigation works correctly.

Monitor Redirects

Regularly check your redirects to ensure they’re working correctly and not creating redirect loops or leading to dead ends. Redirect loops happen when a URL is redirected to another URL that eventually points back to the original URL, creating an infinite loop that can cause browsers to display an error message. This makes it hard for users to reach the content they’re looking for and will negatively impact your SEO rating.

Tools like the Redirection plugin can help you monitor and manage these redirects efficiently, but it’s always worth manually testing your website to see what the average user would experience as well.

Minimise Redirect Chains

Avoid having multiple redirects in a chain as this can slow down page load times and dilute link equity. Each additional redirect in a chain increases the time it takes for the final page to load which can negatively impact user experience and SEO.

Try to have a single redirect from the old URL to the new URL whenever possible.

Inform Search Engines

Use Google Search Console to inform search engines about significant URL changes and monitor for any issues. By submitting a change of address in Google Search Console, you can help ensure that search engines index your new URLs promptly and that any potential issues are identified and resolved quickly. This step is important for maintaining your site’s visibility in search engine results pages.

By following these best practices, you can effectively manage URL redirection, ensuring a smooth transition for both users and search engines while preserving your site’s SEO integrity.

Handling Common URL Redirection Issues in WordPress

While setting up URL redirects is relatively straightforward, you might face some common issues that lead to problems such as redirect loops and redirect chains. So here’s how to handle them:

1. Redirect Loops

A redirect loop occurs when a URL points to another URL that eventually points back to the original URL, thus creating an infinite loop that causes the browser to display an error message.

Solution: Check your redirect rules carefully to ensure there are no circular references. Use tools like the Redirection plugin to detect and resolve redirect loops.

2. Redirect Chains

A redirect chain happens when a URL is redirected to another URL, which in turn redirects to yet another URL. While this doesn’t lead to errors, it can cause slower page load times and loss of link equity.

Solution: Simplify your redirects by ensuring each URL directly points to the final destination without intermediate steps.

3. Incorrect Redirects

Setting up incorrect redirects can lead users to irrelevant pages, causing confusion and increasing bounce rates.

Solution: Double-check your redirect rules to ensure they point to the correct target URLs. Test the redirects thoroughly before deploying them. One of the best ways to do this is to use your website from the perspective of a user, clicking links as they would to identify incorrect redirects.

4. Broken .htaccess File

Incorrect modifications to the .htaccess file can break your site, causing it to become inaccessible or leading to redirection issues.

Solution: Always backup your .htaccess file before making changes. If you encounter issues while modifying it, restore the backup file to revert to the previous state. Alternatively, you can opt to use WordPress plugins instead as they’re often more reliable.

5. 404 Errors from Redirects

Sometimes, setting up a redirect incorrectly can result in a 404 error where the browser can’t find the requested URL.

Solution: Ensure that the target URL in your redirect rules exists and is correct. Regularly monitor your site’s 404 logs and update or fix redirects as necessary. You can use plugins to track 404 errors and quickly set up redirects to the correct URLs.

6. SSL/TLS Certificate Issues

Redirecting from HTTP to HTTPS can sometimes lead to issues if your SSL/TLS certificate isn’t configured correctly or has expired.

Solution: Ensure that your SSL/TLS certificate is properly installed and up to date. Use tools like SSL Labs to check your certificate’s validity and configuration. If you face persistent issues with your SSL/TLS certificates, contact your hosting provider for assistance. Correct SSL configuration not only helps with redirects but also enhances the security and trustworthiness of your site.