How to Fix WordPress Redirection Not Working?

How to Fix WordPress Redirection Not Working? - GuidingCode

Have you been getting headaches because a page redirection on your WordPress site isn’t working?

I mean, imagine if you give your site visitors a broken redirect, wouldn’t they be upset and look for another website?

What’s more, if you incorrectly do it, there are many potential effects, including traffic loss and reduced PageRank in search engines (who would want that?).

Therefore, it’s important to make sure that you fix your redirect before the visitor faces an issue and leaves your website altogether.

So, we decided to create this post to show you five simple fixes 👌 to successfully perform page redirection on your WordPress site. Hence, ensuring your visitors won’t leave, keeping your bounce rate low!

If that sounds interesting, let’s jump in!

 

 

What is a Page Redirect?

A page redirect is when a visitor goes to one page, and you redirect them automatically to another page.

The most common cause for doing this could range from:

  • Redirecting a 404 page to another page
  • Changed the URL of a page
  • Performing a temporary redirect
  • Changed your website’s domain name

 

At the end of the day, you don’t want your visitor to land on a broken page and potentially lose them.

Unfortunately, WordPress websites don’t have an innate URL redirect function 🤔.

The easiest way around this problem in your WordPress site is through a redirection plugin (Step 1), which will also save you time and effort 😉!

 

 

5 Ways to Fix a WordPress Page Redirection Not Working

1. Use WordPress Website Redirection Plugins

There are several different plugins that you can use to fix your page redirect problems. These solutions are very simple and usually done with a few clicks. Most of them are even for free!

On that note, the redirection plugins we recommend for your WordPress website are:

using Yoast SEO premium plugin to perform page redirection to fix WordPress page redirection not working

 

There is a downside to using plugins though. Having too many plugins installed on your WordPress website can potentially slow down the entire website. Plus, as you know the site speed is considered a crucial search engine rankings factor.

So, if you’re worried about the speed of your website and don’t want to install another plugin, then you can choose to redirect using the .htaccess file instead. (Step 2)

 

 

2. Perform Page Redirection Using the .htaccess File

So, you might be wondering, what exactly is a .htaccess file? What does it do?

Well, the .htaccess file is located in your website’s root folder. Essentially, it tells the server how to handle certain things on your WordPress site. Hence, it making it perfect for site management tasks such as:

  • Redirecting visitors
  • Authorization
  • Cache-control
  • URL rewriting
  • Set server configurations
  • Create and use custom error pages
  • Password protect folders
  • Ban or allow users (IP addresses)

 

If you go to your WordPress dashboard and click Settings > Permalinks, you have the option to select the structure of your URLs. The .htaccess file will be configured by WordPress automatically to implement the URL structure you picked.

The good thing with redirecting through the .htaccess file is that you don’t need to use plugins and risk slowing down your website.

Usually, tinkering with this .htaccess file may seem overwhelming for non-technical WordPress users. However, not too fear, we’ll guide you through every step to set up your page redirection using the .htaccess file.

In this case, to redirect your visitors using the .htaccess file, first:

  1. First, Log in to your cPanel or Host provider.
  2. Access the File Manager.

Configure redirection through cPanel to fix WordPress redirection not working

 

  1. Then, click on the public_html folder.
  2. Here, you will find the .htaccess file.
  3. After that, double-click the .htaccess file or right-click and choose edit.

Perform Page Redirection Using the .htaccess File to fix WordPress redirection not working

 

  1. Next, scroll down to the bottom and paste the code redirect 301 /old-url/ /new-url/ on a new line.
  2. Finally, click Saves Changes and you’re done!

 

Note: Always backup the .htaccess file before attempting to make any changes to it. The .htaccess file is the configuration file for your whole server. Therefore to download a safe backup of your .htaccess file:

  1. First, right-click on the .htaccess file
  2. Then, choose Download.

 

Attempting redirection in the .htaccess file with codes requires you to do it properly. Otherwise, you can risk breaking the site 💣 or creating page errors

 

 

3. Set Up Redirection with Cloudflare

If you didn’t know, Cloudflare is actually a DNS that can serve your website through a network closest to your website visitor. Thus, ensuring that your site visitors get the most optimal and fastest page load times. 

Therefore, it’s used by many websites to increase site speed 💨 (which search engines and your visitors love), and protect 🛡️ your website against threats like SQL injection.

But that’s not all. In this case, you can use the Page Rules function of Cloudflare to perform a WordPress page redirect. Redirecting with Cloudflare doesn’t require codes or WordPress plugins, and you can use it for free. Hence this might be just the right fix when your WordPress page redirection isn’t working.

Before proceeding, ensure that you have a Cloudflare account and have connected your WordPress site to it. This allows you to enjoy all the benefits and perks Cloudflare has to offer, including their prized and fast CDN and their nifty Page Rules function we’ll be using.

That being said, to use Cloudflare to redirect pages on your WordPress site:

  1. First, log in to your Cloudflare account. (or register for one, it’s free!)
  2. Then, choose the domain you want to configure. (if you have multiple domains connected)
  3. Among the blue menu icons, click on Page Rules > Create Page Rules. Then, a new window will appear.

set up page redirection on Cloudflare using Page Rules to fix WordPress redirection not working

 

  1. On the first text box (under If the URL matches) enter the current/old URL.
  2. Next under the “Then the settings are” section, choose Forwarding URL, then select the redirect type of your choice (301 permanent or 302 temporary redirects).
  3. Then enter your new URL you want the old URL to be redirected to.
  4. Lastly, click Save and deploy and you’re done.

set up page redirection on Cloudflare using Page Rules to fix WordPress redirection not working

 

Note: Sometimes it can take up to 5 minutes before the page redirect is established.

 

While Cloudflare is free, it only allows you to create up to 3-page rules. If you want more, you’ll have to upgrade your plan.

set up page redirection on Cloudflare using Page Rules to fix WordPress redirection not working

 

 

4. Configure Redirection Through cPanel

Most domain web hosting providers provide their users with a cPanel. Basically, it’s a web control panel software with great UI that makes it easier for users to manage their website and server.

Hence, in this cPanel you can find functions and controls like:

  • File Manager
  • Databases
  • Zone Editor
  • Website Email
  • Redirect

 

The best thing with redirecting through the cPanel is that you don’t need any codes or plugins. Hence, it serves as a great alternative option for when the page redirection on your WordPress website isn’t working.

With that said, to redirect a page on your WordPress site through the cPanel:

  1. First, log in to your cPanel
  2. Then, under the Domain section, click Redirect. (a window will appear)
  3. After that, choose the type of redirect. (301 permanent or 302 temporary redirects)
  4. Next, select the domain you want to implement a page redirect. (www.example.com)
  5. Following that, enter the old URL without the trailing slash. (since the / is already provided in the text box)
  6. Now in the Redirects To box, enter the full URL for the new URL. (www.example.com/new-url)
  7. Before finishing, you can choose to add www or without www depending on your website URL structure. (if you use www.example.com or example.com)
  8. Finally, click Add and you’re done.

Configure redirection through cPanel to fix WordPress redirection not working

 

To use this method, your Hosting provider must have the cPanel functionality. And it’s not very convenient if you want to redirect multiple URLs, because of how time-consuming it can be.

 

 

5. Use the Functions.php File for Redirection

The WordPress functions.php file is a template that’s included in your WordPress site’s theme. Basically, it’s used to activate features or change default functionalities to your WordPress website, using PHP code.

So, just like the .htaccess file, you can include a code in the functions.php file to perform a page redirect, and it doesn’t require any plugins.

Therefore, to perform a page redirect using the functions.php file:

  1. First, log in to your cPanel or Host.
  2. Then, access the File Manager.

access File manager through cPanel of WordPress website to use Functions.php file for page redirection to fix WordPress redirection not working

 

  1. After that, open the public_html folder.
  2. Next, open wp_content and then themes.
  3. In the themes folder, open the folder of the theme you’re currently using. (if you have several themes installed, you will see a folder for each theme)
  4. Scroll down to find the functions.php file and open it.

use Functions.php file for page redirection to fix WordPress redirection not working

 

  1. Following that, paste the code below into the functions.php file
  2. Replace the ‘old-url-slug‘ with your old URL (www.example.com/old-page-url)
  3. Then replace the ‘/new-url-slug‘ with your new URL (www.example.com/new-url-page)

 

Code to Paste into Functions.php for page redirection:

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();

    }

}

 

Note: Make sure you only include the part of the URL after the trailing slash for the old URL (old-page-url) and with the trailing slash for the new URL (/new-page-url).

 

The root folder is a very sensitive part of your whole website, so tinkering with the files inside needs to be done properly. And just like the .htaccess file, it comes with the risk of breaking your website  💣or causing issues.

Luckily, by following the steps above, they should guide you through each step without running into any fatal errors.

 

 

Conclusion

To sum up, this is our complete guide which shows you 5 easy ways you can implement a page redirection in your WordPress site.

For beginners attempting to redirect, we recommend using Yoast SEO. It’s a plugin you most likely already have, if not, should be using to rank your site. (Step 1)

Perhaps you have another SEO plugin installed or would prefer a method without any interfering or obstructive plugins. In that case, you can try the cPanel method instead (Step 4). Plus,  it’s relatively simple and safe, and if any errors occur, the support team of your host provider should be happy to help you.

Before you go, we would love to hear from you in the comment section below 😁:

  • Are you encountering issues with a WordPress page redirection that’s not working?
  • Did you find any of the tips above useful?
  • Do you have another fix we can add to the list?

Feel free to share this with someone you know that needs help with redirecting WordPress pages. 👂

 

 

Total
0
Shares
Leave a Reply

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

Related Posts
Total
0
Share