How To Redirect A Page In WordPress


Redirect a page in WordPress

If you are looking to redirect a page or any URL in your WordPress site, this guide is for you. We’ll discuss everything you need to know about redirecting a page in WordPress.

Redirects are a necessity – whether it’s preserving SEO rankings, improving user experience, or maintaining your website or to making your WordPress site secure. So, lets dive into the agenda.

Table of Contents

What are Redirects?

Simply put, page redirection is used on websites to guide both users and search engines from one URL (web address) they initially requested to a different URL. Why? – This ensures that users and search engines can find the content they’re looking for, even if the old page or URL has been updated, moved, deleted or the website structure has been updated.

When to use redirects?

Whether you moved a page and you want to ensure visitors don’t land on the empty 404 page, or you want to fix a broken link or lead your visitors to the new content – you’ll need redirects.

Replace outdated content

When you update your website with new content, replacing pages that are outdated or no longer relevant, use WordPress redirects so that the users seeking information are always met with the most valuable content.

If you decide to remove a page from your website, or the content is outdated, setting up a redirect to a similar page keeps users from landing on a dead end. Broken links occur when a redirected URL points to a page that doesn’t exist, leading to a 404 error.

Whenever you change the permalink structure or the URL slug of your posts or pages, you’ll need to redirect the old page URL to the new content’s URL.

Website Structure

By strategically using redirects, you can guide visitors to the appropriate content, even as you enhance and refine your website’s structure.

Domain name changes

Changing your website’s domain name is one of the most significant changes and redirects ensure that users attempting to visit your old domain are smoothly directed to the new one. When correctly implemented, this preserves your search engine rankings.

Types of Redirects

301 Redirects

A 301 redirect is a permanent redirect and it indicates that the original page’s content has moved to a new URL. This is the most commonly used redirect in SEO to transfer the SEO value & link equity to the new page.

302 & 307 Redirects

302 redirects are used for temporary situations and condition based redirects like location specific. For example, you are selling a product as a Christmas offer and after the Christmas is over, you can use 302 redirect to relevant product pages without a Christmas offer and use the offer page next Christmas. 

In another example – if your product’s details vary with location, you can redirect your visitors to the right versions of your page by utilising 302 redirects. Similar to 302s, 307 redirects are also temporary. However, they are used in HTTP 1.1 environments and ensure that the method and body of the original request are not changed during the redirect.

HTTP/HTTPS Sitewide Redirects

If you have http links in your website, implementing redirects to relevant HTTPS versions of pages ensures that your visitors always have a secure connection and builds trust with your audience. Sitewide redirects are used when you need to redirect all pages from one domain to another.

How to redirect a page in WordPress?

WordPress offers several methods for redirecting pages: using plugins, editing the .htaccess file, or utilising WordPress functions.

How to redirect a page in WordPress without a plugin?

Redirecting a page in WordPress without using a plugin can be done in two ways: editing the .htaccess file or using PHP redirects. Remember to make backups and be careful while making the changes to these files as it may break your site.

Using .htaccess file

The .htaccess file is a powerful configuration file used by Apache web servers that allows you to perform a wide range of website system & management tasks, including redirects. To use this method for redirecting a page in WordPress:

First, you need to access your site’s .htaccess file. This file is located in the root directory of your WordPress installation. Use an FTP client or your web hosting control panel’s file manager to find your WordPress site’s root directory. 

Once you’ve opened the .htaccess file for editing, you can add your redirect rules. For a basic 301 redirect, which is used for permanent redirects, the syntax is straightforward:

Redirect 301 /oldpage.html /newpage.html

This line tells the server that the oldpage.html has permanently moved to newpage.html. Replace /oldpage.html with the old URL (relative to the root of your site) and /newpage.html with the new URL.

Using PHP Redirect

This method requires adding a PHP code to your theme’s functions.php file. 

To create a redirect using PHP, Access your WordPress theme’s functions.php file using an FTP client or through the Appearance > Theme Editor in the WordPress dashboard.

Add the following PHP code at the end of your functions.php file:

add_action(‘template_redirect’, ‘custom_page_redirect’);

function custom_page_redirect() {

    if (is_page(‘old-page-slug’)) {

        wp_redirect(home_url(‘/new-page-slug/’), 301);

        exit;

    }

}

Replace ‘old-page-slug’ with the slug of the page you want to redirect from, and replace /new-page-slug/ with the slug of the page you want to redirect to. This code checks if a visitor is accessing the old page and redirects them to the new page with a 301 status code, indicating a permanent redirect.

How to redirect a page in WordPress with a plugin?

Plugins make it easy to manage redirects without needing to edit your site’s files directly. There are several plugins available for redirecting pages in WordPress, such as Redirection and RankMath

JcM59 oLA OYq1kK XJdSWsO0RDuO HQMbSErUv00VqG9BDxG

Using RankMath SEO plugin

Go To WP Admin >RankMath SEO > Redirects > Add New. The form will appear as shown below. Here, add your source URL/Destination URL & matchtype, choose the redirect type and add scheduled activation/deactivation date as necessary. Then, click on Add Redirection and it’s done. 

CdUsC5rxQGoTGWxbNiFaIHOrfC6DXh0KebnYK9qFNDskw6RmIvhLBVlEncS06m6 8so8gJdmrt90RN3ZhEE5e07YSuZC43YngmB325ya8QItvkfD 3OF6zp0E0j wkT5

Using Redirection plugin

The Redirection plugin is a simple and powerful tool for managing 301 redirects, tracking 404 errors, and tidying up any loose ends your site may have. To add redirects with this plugin go to the WP Amin>Tools>Redirection and click on Add New at the top of the page. Then, Add the old URL and the new, target URL and select type of redirection.

image
ZoQeA6SmOJpZbj 2vdoGv7kQt awqVVVMa5EN2Z9ZrQb2KRl8m

Why use redirects?

Redirects are essential for fixing broken links, accommodating site restructuring, and enhancing SEO by consolidating duplicate content.

By using redirects thoughtfully, you can maintain and even enhance your site’s performance, security, and SEO, making it clear that the benefits of redirects extend far beyond mere convenience.

User Experience

Redirects help to solve 404 error pages, guiding visitors to the content they are looking for. This not only improves experience but also increases the likelihood of conversions and return visits.

Imagine this – you’ve done an excellent job marketing a specific product or article, driving a significant amount of traffic to its page. However, if that page’s URL changes without a redirect, your visitors will be greeted with a 404 error page. Not only does this frustrate users, but it also diminishes trust in your site and leads.

SEO

Redirects are crucial in maintaining and improving your site’s SEO. By properly redirecting old URLs to new ones, you signal to search engines like Google that your content has moved, and preserve rankings. This is especially important during site migrations, rebranding, or after restructuring your website.

Need help maintaining your WordPress website? We are WordPress website experts in Sydney. Send us a message.


Updated on: 5 March 2024 |


Sazjan Neupane

Sazjan Neupane

Sazjan helps us reach our dream clients with his expertise in Search Engine Optimisation, PPC, Project Management & Online Business Development. He has worked with a variety of clients in different industries over the last 5 years. In his free time, Sazjan enjoys traveling and exploring new cultures.