You are currently viewing How to WordPress redirect page without a plugin in USA 2021

How to WordPress redirect page without a plugin in USA 2021

  • Post comments:0 Comments

If you’re confused How to WordPress redirect Page without a plugin in USA 2021 the way to send your WordPress URLs, then this text can clear the cloud of doubts over your head.


Also called “URL forwarding”, URL Redirection may be a technique accustomed to virtually send your site’s users from one domain or page to a different. It’s doable to decide on any online page on the web to send your guests to, however, it’s sometimes used for redirecting them among constant web site.

Normally, this involves putting in a plugin to airt a page in WordPress. whereas that’s not a foul plan, it’s a touch excessive if you simply need to airt one or 2 pages. during this tutorial, I’ll show you the way to accomplish this while not a plugin. Either exploit your functions.php go in your themes directory, or via a PHP code inserter.

1. WordPress redirect page through cPanel

If you don’t wish to use a plugin to redirect URLs and use cPanel hosting, this option will be appropriate.

The process is super easy and simple.

Step 1: Head over to your hosting’s cPanel and under “Domains”, click on “Redirects”. You should see a similar screen like this with several options to choose from.

WordPress redirect page without a plugin

Step 2: within the “Type” dropdown box, you wish to pick the type of redirection you wish to try and do, whether or not it’s permanent (301) or temporary (302). relying upon the link you wish to airt to, it ought to be simple to decide on between the 2 choices.

Step 3: within the second dropdown menu, you wish to pick your domain + current page address.

Step 4: Once you’ve done that, within the last field, you have got to kind the online page address, that ought to replace your current page address.

Click “Add” and you’re done.

2 Step(1): Get the “From” uniform resource locator (URL) Slug and also the “To” uniform resource locator (URL) Slug to WordPress redirect page without a plugin

Before we have a tendency to get into the code, you wish to specifically write down 2 things:

  • Which uniform resource locator must be redirected
  • To that uniform resource, what locator ought the users go to?

There are a number of obstacles here. First, check and see whether or not URLs on your website finish with a “trailing slash” or not. In different words, ar you this:

or this:

To send a page in WordPress, we’re reaching to be matching strings in code. It’s very necessary to grasp precisely however your URLs are written.

Once you have got the URLs, produce the universal resource locator slugs. The “slug” is that a part of the universal resource locator while not the name, or https (or http).

So for the on top of example, the slug can be:


Similarly if your URL is;

The slug will be:


Note the initial slash “/” in front of the slug. This is going to be important.

Why Use Slugs and Not URLs? in WordPress redirect page without a plugin

In case you’re speculative why we have a tendency to don’t do a straightforward uniform resource locator matching, the explanation is straightforward. we would like to insulate ourselves from potential changes.

perhaps you produce a subdomain for a page, or move your journal into a directory. maybe you’re exploitation the protocol protocol and in some unspecified time in the future need to maneuver to HTTPS.

Without the slug, all of your tries to match the uniform resource locator can fail as a result of the initial half is ever-changing. however, the slug is eternal. The slug is forever!

Step 2: Code in functions.php to Redirect a Page in WordPress

The second step is to open your “functions.php” file located in your theme (preferably a child theme). Now paste the following code into it:

function redirect_page() {

     if (isset($_SERVER['HTTPS']) &&
        ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
        isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
        $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
        $protocol = 'https://';
        else {
        $protocol = 'http://';

    $currenturl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $currenturl_relative = wp_make_link_relative($currenturl);

    switch ($currenturl_relative) {
        case '[from slug]':
            $urlto = home_url('[to slug]');
    if ($currenturl != $urlto)
        exit( wp_redirect( $urlto ) );

add_action( 'template_redirect', 'redirect_page' );

In this code, there are two sections in bold. Namely this one:

case '[from slug]':
    $urlto = home_url('[to slug]' );

This is where you enter your “from” and “to” slugs. Replace the sections in bold including the square brackets with the slugs you got from Step 1.

Save your changes, and now when you visit the “from” page, you should be redirected to the “to” page.

Step 3: Add More Redirects

I’ve structured the code in such a way that you can easily add more redirections if you want. For each new redirection, just place a new section like this under the first one:

case '[from slug]':
    $urlto = home_url('[to slug]' );

case '[from slug2]':
    $urlto = home_url('[to slug2]' );

Just make sure you keep the line “default” after all these “case” blocks and you should be fine. You can now redirect as many pages as you want to other pages without using a WordPress plugin

Some Other Post For WordPress redirect page without a plugin in USA 2021

Leave a Reply