Quantcast
Channel: InstaWP
Viewing all articles
Browse latest Browse all 998

Guide to Setting Up Redirects in WordPress Without Losing SEO

$
0
0

It is important to set up redirects in your WordPress site, whether for setting up custom 404 pages, making permalink changes, optimizing URLs, changing directories, or deleting outdated pages. You will learn how shortly.

What Are Redirects in WordPress?

WordPress Redirect is simply the forwarding or mapping of a non-existent URL to an existing URL. When visitors or search engines try to access the non-existent URL in a live WordPress site, redirects automatically take them to the page with the new URL. 

This simply means that when a visitor tries to visit page A, the visitor will be forwarded to page B instead because page A no longer exists on that site.

Redirects usually occur when you delete a URL from your site, change permalinks, change a page URL, or perform site maintenance. They don’t just happen independently; you have to set them up yourself.

WP-Cron

How Redirects Impact SEO and User Experience

When WordPress redirects are not set, visitors and search engines will be taken to a 404 error page, which is bad for any website. URLs sent to a 404 error page aren’t good for SEO or user experience. 

When search engines detect that a URL being ranked in SERPs is being sent to a 404 error page and not the content originally there or similar content, the URL will immediately be classified as a broken link and removed from search results.  

Redirects also ensure your visitors find the content they desire, keeping them engaged and satisfied and providing a good user experience.

Types of Redirects in WordPress

WordPress has four main types of redirects: 301, 302, 307, and 404 Redirects. However, the most common redirects are the 301 and 302 redirects. 

Overview of 301, 302, 307, and 404 Redirects

301 Redirect (Permanent Redirect or Moved permanently)

This is a permanent redirect. You use a 301 redirect when you change a URL and do not intend to use that URL again. When a 301 redirect is set, search engines will understand that the content they are ranking has been permanently moved to the new URL. So, instead of removing the URL from the SERPs, they simply transfer all its SEO ranking and link equity to the new URL. 

Furthermore, existing bookmarks and backlinks on other people’s browsers, websites, and blogs will be preserved and safely redirected to the new URL.

302 Redirects (Found or temporary)

This is a temporary redirect. You use a 302 redirect when changing a URL for a short period and then reusing it. You may change URLs for a site redesign or to fix issues. 

It is like temporarily moving the products from a particular section of a supermarket to another section to make room for cleaning, fixes, or upgrades and returning them when done. When a 302 redirect is set, SEO authority or link juice is not transferred. 

307 Redirect (Temporary Redirect)

This is also a temporary redirect. However, you use a 307 redirect to preserve the HTTP request method. This redirect tackles issues related to GET and POST requests, such as how forms on that page should handle data submission.

404 Error (Not Found)

This is an error page. A 404 error comes up when a URL is invalid or has been removed. This page is helpful when there are broken links on your site, or visitors make mistakes when typing the URL. You can redesign the 404 page by including a custom message and a button back to the home page or suggesting other related pages or content on the site.

Differences and When to Use Each Type

Redirect CodeType of RedirectUse case
301Permanent redirectChange in domain or permalink structure
302Found / temporary redirectSite maintenance or page upgrade, out-of-stock product
307Temporary redirectChange in form submission
404Not FoundBroken link

Benefits of Setting Up Redirects

Redirects ensure that site visitors and search engines always find relevant content when they attempt to access any URL on your site. This can be beneficial in many ways, including:

1. Improving Site Navigation and User Experience

Redirects boost user experience by ensuring your site visitors find relevant content. They also provide a smooth and hitch-free transition from one page to another, especially for internal links.

2. Preserving SEO Rankings After Content Changes

Search bots can penalize your site when the content they rank in SERPs is no longer accessible. Three hundred-one redirects transfer SEO value from the old URL to the new one, ensuring you don’t lose search engine ranking and organic traffic.

3. Managing 404 Errors Effectively

When left to default, the 404 error page displays a large white empty page with 404 inscribed. You can tweak it by adding suggestions to alternative pages. Doing this will reduce the bounce rate and improve user engagement.

Caution: Test Your Redirection Method in Staging First

As you will see shortly, setting up redirects involves making critical changes on your WordPress site. So, before you think about doing it on a live site, you should test it in a staging environment first to avoid any unwanted errors, downtime, or impact on SEO. We recommend using a tool like InstaWP to create WordPress staging sites.

InstaWP allows you to quickly set up a staging site away from your hosting server, which you can use to set up and test Redirect rules. The two-way sync feature allows you to implement the Redirect rules on the live site with just a few clicks, meaning you do not have to repeat the process.

How to Set Up Redirects in WordPress using a Plugin

Several WordPress plugins make it easy to set up redirects in WordPress. Some of these plugins include:

Step-by-Step Guide to Creating Redirects Using Plugins

Most WordPress redirect plugins have a similar procedure for setting up redirects in WordPress:

  1. Install and Activate the Plugin
  2. Locate the Redirect section
  3. Enter the old URL, new URL, and redirection type
  4. Save and test the Redirection

 This article will explain the step-by-step process for setting up redirects in WordPress using the Rank Math plugin.

Go to the WordPress plugin directory and install Rank Math.

Activate it and set it up with the setup wizard. You are at liberty to skip the wizard.

Go to your Rank Math dashboard and locate the Redirections module. Switch the toggle on. You can click on Settings to configure how the redirection works by default. 

rank math redirection module

From the side menu, click Redirections.

Click on the Add New button at the top, and enter the URL(s) you wish to redirect and the destination URL. Select the type of redirect and click on the Activate button.

adding redirects with rank math plugin

How to Create Manual Redirects via .htaccess File?

Another effective way to set up redirects is to use your WordPress .htaccess file. This is a manual process that requires some technical know-how.

Note: Please try to back up your .htaccess file before implementing this process so you have a working file to fall back on if something goes wrong. You also need to confirm that you can modify your server’s file.

Go to your hosting cPanel or fire up an FTP client.

Go to File Manager > root directory and locate your .htaccess file. If you can’t see it, turn on the option to show hidden files.

Open the .htacess file with the code or text editor.

Add the appropriate redirect code at the bottom of the file. Use the following format:

# 301 redirect – single pageRedirect 301 /old-URL https://www.example.com/new-url
setting redirects with .htaccess

From the code above, you will see that you specified:

  • the type of redirect – Redirect 301
  • the old URL – /old-url
  • and the new URL – https://www.example.com/new-url.

These same three parameters and code format also apply to the other types of WordPress redirects.

If you wish to redirect an entire site to a new domain, simply omit the old URL and use a direct redirect rule, as shown below:

# 301 redirect – site-wide Redirect 301 / https://example.com/.

When done, save your changes and test the redirection by visiting the old URL and confirming that you were forwarded to the new URL.

Note: You can also use plugins like Rank Math to edit the .htaccess file in WordPress.

editing .htaccess with rank math

Redirecting Custom Post Types and Taxonomies

We often neglect to redirect custom posts and taxonomies, including categories, tags, etc, when we delete or change them. However, it is also equally important to set up redirects for them.

How to Redirect Custom Post Types

You can use plugins like Redirection, Rank Math, and Yoast SEO Premium to redirect custom post types. You can redirect single posts by including the path of the custom post in your URL (e.g., /my_custom_type/old-post) and the destination URL.

Rank Math can also automatically apply redirects when you change the URL of any page, including custom post types.

To enable this option in RankMath, go to General Settings > Redirections.

Toggle on Auto Post Redirect and click Save Changes.

Enabling auto custom post redirect with rank math

However, if you wish to redirect all posts of a custom post type, you can use the WordPress function.php or the .htaccess file.

Enter the following code in your functions.php file to use the WordPress function.

add_action( ‘template_redirect’, ‘redirect_post_type_single’ );function redirect_post_type_single(){ if ( ! is_singular( ‘YOUR-CUSTOM-POST-TYPE’ ) )        return;    wp_redirect( get_page_link( YOUR-PAGE-ID ), 301 ); 

Note: Replace YOUR-CUSTOM-POST-TYPE with the name of the custom post type and YOUR-PAGE-ID with the ID of the page to which you want all posts under the custom post type to be redirected.

To use the .htaccess file, enter the following code:

Redirect 301 /my_custom_type/old-post /new-url

Ensure to replace my_custom_type with the name of the custom post type.

Managing Taxonomy Redirects for Better SEO

Yoast and Rank Math are better equipped to manage taxonomy redirects without impacting SEO. When Auto Post Redirect is enabled in Rank Math, it automatically redirects taxonomy, including categories, tags, etc. 

Testing and Monitoring Redirects

It is a good practice to always check your site for broken links and failed redirects. You can test and monitor redirects using the following tools:

  • InstaWP: You can use InstaWP to create staging sites for testing new and existing redirects without affecting user experience. You can sync those changes with your live site when you confirm everything is working.
  • Redirect Checker: Redirect Checker is a WordPress plugin you can install on your site to check if redirects are functioning properly.
  • Google Search Console:  When you add your site and submit your sitemap in Google Search Console, Google will continue to monitor and crawl your site for errors and redirects and provide feedback when any issue is found.

Common Redirect Mistakes to Avoid

Here are some common redirect mistakes to avoid to ensure a smooth user experience and maintain your SEO performance:

  1. Setting redirect loops, e.g., page A redirects to page B, and page B redirects to page A.
  2. Setting multiple redirects in a chain, i.e.page A redirects to B, page B redirects to C, and so on.
  3. Using 302 redirects for permanent moves instead of 301 redirects can prevent the transfer of SEO equity.
  4. Failure to set up redirects immediately after deleting a page.
  5. Failure to test redirects on a staging site, which, when done on a live site, can lead to errors or negatively affect SEO.
  6. Internal links are not updated after changing the aa URL with the new URL.
  7. Redirecting every URL to the homepage instead of relevant content.

Best Practices for Effective Redirects

  • Regular Auditing: Regularly auditing redirects with tools like Screaming Frog or redirect plugins will help you identify broken links, chain redirects, loops, and outdated or no longer necessary redirects so you can modify or remove them.
  • Use Clear and Descriptive Redirect URLs. This will positively impact your SEO and prevent you from changing the URL.
  • Keep Redirects Simple: Avoid using long chains, loops, and complex redirects. They can affect page loading time, increase bounce rates, and cause SEO issues.

Conclusion

Redirects are relevant and simple to implement in WordPress. As a site owner, you must consciously set up redirects to preserve your search traffic, link equity, and visitors. This article will always be here to guide you in doing it yourself.

FAQs About WordPress Redirects

What is the difference between 301 and 302 redirects?

301 redirects are for permanent URL changes, while 302 redirects are for temporary URL changes.

How can I check if my redirects are working?

You can use a staging site, the Redirect checker plugin, and Google search console crawl reports to check if your redirects work.

Can redirects affect my site’s loading speed?

When done right, redirects do not affect site speed. But if you use a long chain or multiple redirects (e.g., A → B → C → D → E), the experience will be slow.

How do I redirect a page in WordPress without a plugin?

You can manually set up page redirects by editing your WordPress site’s functions.php or .htaccess file.


Viewing all articles
Browse latest Browse all 998

Trending Articles