How to Redirect a URL in WordPress?

How to Redirect a URL in WordPress?

When you want to change an existing website’s structure, you might want to consider fixing broken links or moving to another domain entirely.

If that’s the case, a URL redirection is the best option you will have.

Not only does it redirect users from an old broken link to a fresh new one, but it also ensures that the SEO of a website remains unaffected too.

Stay with us till the end as we take a more in-depth look into redirecting a URL, along with its types, scope, and a how-to-use to guide.

What is URL Redirecting?

Redirecting refers to the process of mapping one object to a different one. In URL redirection, a user is transferred from Page A to Page B while using the URL of Page A. This process of remapping a web page address to a new address is called URL redirecting.

It is also called URL forwarding and is a technique for making web pages available under more than one URL address. The information available on one URL address is moved to a new page in this process. This process helps users, as well as search engine web crawlers, locate the information.

Types of Redirects

There are 5 different commonly used types of URL redirection: 

301: 

The 301 redirect, used when a page is moved to a new address permanently, keeps your search engine rankings intact, and is the best redirecting technique. 

302: 

302 redirect is a temporary redirection technique. It serves as an alternate when the requested page is temporarily unavailable. 

303: 

This redirect was created to replace the 302 redirects. It prevents screen refreshing and bookmarking of sensitive data such as passwords.

307: 

The 307 redirect is very similar to the 303 redirect. The only difference is that 307 redirect uses the same technique to send as well as receive information. Whereas 303 uses two different methods.

In this article, redirecting refers to 301 redirects as it is the most common redirecting technique used in WordPress. 

Why Redirection is Important?

URL redirecting is a technique mainly used to fix technical errors or inform search engines that the page has moved. Given below are the few cases when redirects are useful.

Technical Errors

Redirects can help you guide new users to your website without any confusion. In some cases, when a user requests a website, they might not find it there. Chances are there might be a typo in your URL or simply because the page is moved to a new URL address. 

Most of the time, you’ll see a 404 error page whenever such cases occur. You also have the option to redirect your users back to your original page. Redirects can help you regain your visitors that you may lose. 

Updating Websites

As your business grows, your strategies, policies, and plans change. Your domain name might also change, especially when smaller companies tie-up with more prominent companies. 

No one wants to lose their hard-earned reputation while they are growing in their business. Thus, redirects can help you keep your legacy intact by keeping your clients with you and directing them to the new page.

Directory Structure Changes

At times when you want to rearrange the structure of your website, you can use redirects. This changing or rearranging of website structure can either be for general reorganization or even for security reasons. Sometimes website owners also arrange the structure to optimize the site. Using redirects during such times ensures that your visitors land on the right page. Hence, redirects can save you from the potential loss of clients.

SEO Optimization

While rebranding your website, URL redirection also helps in SEO optimization. It gives you total control over the website’s URLs. Small tweaks like redirecting all HTTP input to HTTPS can boost SEO performance. Besides, redirects can help users get to the same URL from different pages. 

After redirection, search engine crawlers can find the information even when they’re moved to a new location. Thus, URL redirection ensures that your data doesn’t lose its value and worth. 

How to Redirect a URL in WordPress?

There are multiple ways of redirecting a URL in WordPress. We’ll discuss two primary ways–redirection using plugins and manual redirection. 

1. Using Plugin

For general users who find coding tedious, you can use one of the many plugins available for redirecting a URL in WordPress. Plugins maintain standard security of your site and employ redirects. Among many different plugins, here are the three best plugins based on user reviews and features:

301 Redirects – Easy Redirect Manager

301 Redirects is an easy to use and user-friendly plugin that lets you create and manage redirects for your WordPress site. You can create 301, 302, and 307 redirects with ease, whether for new or existing websites. 

This plugin lets you reroute incoming traffic of a requested URL to a different destination URL. It is SEO optimized and helps search engine bots to find the right information at the right URL. 

You can use the 301 Redirect plugin when you need to move to a new website or organize your existing WordPress content. You can also use it on particular time-bound occasions like a sale for eCommerce, events, etc. z

Features:

  • Fast redirection
  • Import Export feature
  • Bulk redirects
  • Redirect stats to help you know the scale of the redirection
  • Custom destination URL

How to Install

  • Download redirection.zip file
  • Unzip/extract. Make sure you unzip the redirection directory to your /wp-content/plugins directory.
  • Go to Plugin Management
  • Enable the plugin
  • Visit Tools/redirection and configure the options.
301 Redirects - Easy Redirect Manager

Redirection

Redirection is one of the oldest and most trusted plugins. It is ideal for 301 redirects, 404 error handling, and fixing broken links. No matter how small or big your website is, the Redirection plugin can work great for all. 

Redirection has been in the business for more than a decade now. It has built an outstanding reputation among its users and is recommended by many. Moreover, Redirection is compatible with PHP 5.6 and onwards. It also helps improve your site’s SEO ranking. 

One of the Redirection's unique features is that it can create redirects automatically when a post or page permalink is changed. 

Features:

  • Easy to use
  • Options for conditional redirects
  • A complete log of redirects.
  • HTTP headers for better security of websites.
  • Track 404 errors
  • Query parameter handling
  • APACHE and NGINX support

How to install

  • Download 301 redirects and unzip the zip file. 
  • Upload eps-301-redirects directory to / wp-content / plugins / directory
  • Go to the “Plugins” menu and activate the plugin.
  • Go to Settings>301 Redirects and add as many redirects as you need.
Redirection demo in redirection plugin
redirection Setting
Redirect Logs
Import_Export redirection plugin setup
Options redirection Plugin
Support in redirection plugin

Simple 301 Redirects

Simple 301 Redirects is a plugin that lets you seamlessly pass incoming links and their page rank from old pages to new pages. It preserves your URL structure and redirects you to some other page or website with ease.

As the name suggests, it is simple and easy to use. However, depending on your hosting provider, redirection might be a bit slower. If you do not want to make your website slow, you can also choose to redirect manually.

Features:

  • Simple and easy to use
  • Seamless redirection
  • Free 
  • Preserves URL structure 

How to install

  • Download Simple 301 redirects, unzip and upload to /wp-content/plugins/directory
  • Go to the “Plugins” menu in WordPress and activate plugins.
  • Go to Settings > 301 Redirects page and add redirects.
Simple Redirect

We have also created a list of Best WordPress Redirect Plugins. So, please do have a look at it too if needed.

2. Manually

If you are a WordPress professional or coding expert, you can manually redirect a URL. Manual redirection is the most efficient, easy, and sustainable technique of redirecting URLs. However, you’ll need to have basic coding skills to understand the steps.

There are two ways in which you can redirect your WordPress page manually. One involves editing the .htaccess file while others involve editing the functions.php file. 

Let’s dig in and find out more:

Using .htaccess file

It is the easiest and quickest way to redirect for those who find it comfortable working with the .htaccess file. The .htaccess file manages all the permalinks of your site. So, whether you want to redirect just a single URL or an entire website, you can do it using the .htaccess file.

To start with, find the URL you want to redirect. Then, decide on the new URL endpoint and note down the mapping for later use. Always remember to back up your WordPress site before making any changes.

  • Go to your website’s file directory. You can access the file directory using a control panel, FTP, or an FTP client like FileZilla.
  • Open .htaccess file in a text editor. If you want to try out a single redirect, add the following lines of code:
Redirect 301 /old-page.html
http://www.mydomain.com/new-page.html

Change the old-page.html to match the old URL, and in new-page.html, modify the URL to match the destination URL.

  • Add the following lines of code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
Rewrite Rule htaccess

These lines of code ensure security by redirecting users to a more secure ”HTTPS” URL.

  • If you want to redirect your entire website to a different URL, add the following lines to your code:
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(>*)$ http://www.mynewdomain.com/$1
[R=301,L]
Rewrite htaccess
  • Save the changes you’ve just made in .htaccess file. If you’re locally working on your .htaccess file, do not forget to upload it to your site’s server.

Using functions.php file

As mentioned above, you can also redirect using the functions.php file in a child theme. Every theme comes with a functions.php file. Every child theme has its functions.php file too. While the functions.php file in your theme may change when you update your theme, the child theme's functions.php file remains unchanged, which is why it is ideal for customization.

  • Locate the functions.php file in your child theme using an FTP client, FTP, or a control panel. 
  • Suppose you plan to redirect your entire site to a single new location, open functions.php with a text editor. Add WordPress' very own wp_redirect function by adding the following lines to the end of the code.
wp_redirect( “http://www.my-blog.com/a-new-destination”, 301 );
exit;
adding redirection in functions.php

Do not forget to change the example URL given above to your destination URL.

  • The wp_redirect function can be used to redirect a single URL. You can also use the wp_redirect function to redirect specific slugs to a new URL.

Conclusion

You should consider redirecting URLs, whether you’re planning to move your website, change the website structure, fix some broken links, or improve the site’s SEO. Finding the perfect method among the above listed depends on the skill level and the condition. Choose the one that serves your purpose well.

We hope you find all your answers you were looking for regarding URL redirection in a WordPress site. Try out the methods listed above and let us know about your experience in the comments below.

Leave a Reply

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