Have you ever edited the post, page, or slug of your site? Then, after doing it, you badly faced the need to redirect your old URL to the new URL. If yes, then read the full article because in this article we will let you know how to redirect a URL in WordPress with a plugin or without a plugin.

In WordPress, you will often need to redirect URLs for making changes in posts, pages, or slugs. Having no knowledge about redirection can create a big problem for you. As I have also faced this problem so I have decided to write about it in this blog.

Table of content:

  • Why do you need to redirect a URL?
  • How to redirect a URL in WordPress with a plugin.
  • How to redirect URL in WordPress without a plugin.

Why do you need to redirect a URL?

At the time of operating your WordPress site, you will face many circumstances when you will badly need URL redirection. Because URL redirection is essential to overcome these circumstances.

You will badly need to redirect a URL in WordPress during the following cases:

  • Suppose you have changed the slug of your post or page then you have to redirect a URL.
  • Moreover, you have edited your post, now you have to redirect your old post to the new post.
  • Or maybe you have changed your permalink for this redirection is needed.

Redirection of a URL needs to be done at the time of facing these circumstances. If you don’t do it then your user will never get your previous post or pages as well as recent edits. The redirection will inform your user’s browser to go to the new URL. You can redirect a URL with or without a WordPress redirection plugin. Here, in this blog, we will discuss both methods.

How to redirect a URL in WordPress with a plugin:

In WordPress, you can find plugins for all functionalities. WordPress also offers plugins for redirection. These plugins will automatically redirect your previous URL to a new URL. You don’t need to bother about the URL redirection. One of the best redirection plugins of WordPress is given below:

Redirection:

Redirection plugin

This plugin will help you to do 301 redirects as well as help you to find out the loose ends of your site. You can also avoid 404 errors by using this plugin. Your site’s ranking will be improved as well. This will let you redirect your WordPress URL without using Apache or Nginx knowledge. Besides, trusted plugin for more than 10 years because it can deal with the site with thousands of redirects. Moreover, this plugin will automatically redirect your old URL to new a URL when you will change your post’s permalink.

This Redirection plugin is super user-friendly as you can redirect with it within few seconds. You can redirect your old URL to new URL by adopting the following steps:

  1. At first, go to your dashboard and click plugin>> add new.
Add redirection

2. After that type Redirection in the search box.

Install redirection plugin

3. Install and activate the Redirection plugin and make the additional setup that needs to setup your plugin.

Redirect a URL in WordPress

4. Go to tools and press Redirection after that.

Redirect a URL in WordPress

5. Now, you have to fill up the source URL and targeted URL box.

Source URL: It is the URL of your old post. You need to enter your old URL in this box.

Targeted URL: This URL is the new URL where you want to redirect your users.

Redirect a URL in WordPress

6. After that, click the wheel-like button that is shown on the picture and select the type of your redirection. Finally, add redirect. Now redirection is done.

Redirect a URL in WordPress

After doing this visit your site and click your old post then it will redirect to the new URL.

How to redirect URL in WordPress without a plugin:

If you don’t like the idea of using a redirection plugin for redirecting URL then you can also do it without a plugin. But, for doing it without a plugin, you will need technical knowledge. Like you need to add coding to your function.php file. No need to worry about it. It’s not like that you can’t do it if you are a beginner and don’t know how to code. All just you have to add the following code in your function.php file:

add_action('wp_print_styles', 'redirect_old_url_to_new_url');
function redirect_old_url_to_new_url() {
    global $post;
    if ('old-url-slug' == $post->post_name) {
        wp_redirect( site_url() . '/new-url-slug', 301 );
        die();
    }
}

After adding this code in your function.php file enter old and new ULR respectively in the old-url-slug and new-url-slug. then save the changes you made. Finally, after clicking your old URL it will redirect you to the new URL. Only adding this code will complete the work of redirecting.

How to minimize redirects on your WordPress site?

Redirect sends your users to the new URL of your site. It helps your user to go on the right path. But using too many redirects will make your site slow and you know how important your site’s speed is. Basically, users don’t go to the site that takes more than 3-4 seconds to load. In fact, your mobile users are more sensitive to it. That’s why don’t use unnecessary redirects to your site. With helpful tips, you can also minimize redirects on your site. Here are some tips to minimize redirects:

  1. Remove those redirects that lead to the pages or posts that don’t exist now. You can scan regularly to remove these redirects.
  2. Deactivate the plugins that you don’t need now and try to use must-have plugins. Because plugins can also cause unnecessary redirects. As a result, this also increases your site’s loading speed.
  3. Always try to avoid redirects that you can. Set the slugs and permalinks of your posts and pages carefully so that you don’t need to redirect to a new URL after editing.