Home WordPress How To Redirect HTTPS to HTTP in WordPress Sites?

How To Redirect HTTPS to HTTP in WordPress Sites?

0
How To Redirect HTTPS to HTTP in WordPress Sites?

Google has been embarking on a journey towards a secure connection. That could explain the reason for the emphasis on using HTTPS for all links. As of 2017, browsers have begun marking the connections without HTTPS as being insecure (Not Secure). The HTTP connections are being treated as a security risk, and there is a planned roadmap to migrate to HTTPS. However, there are several occasions wherein you may want to redirect an HTTPS connection to an HTTP one, however, what necessitates this may be beyond the scope of this article. But we will explain it in a little detail. Let us check out the ways you can use to redirect HTPPS to HTTP.

Why Redirect From HTTPS to HTTP?

Google has been forcing the use of HTTPS for over a year now. Most of the mainstream browsers including Edge, Chrome, and Firefox have been marking sites with HTTP connection as being a security risk.

However, using HTTPS connection has its downside as well. In fact, the HTTPS connection should not have any significant effect on some sites that are entirely lighter. However, sites like E-commerce sites indeed bear the brunt of an HTTPS connection. The HTTPS connection is known to use more server-side resources. This can slow down the site considerably. This can cause severe concerns if you have increased traffic which can transform into the loss of business.

How To Redirect HTTPS to HTTP in WordPress Sites?

Well, now that you understand the importance of an HTTPS connection and why it is most needed, most of us will not want to redirect to HTTP. Even then, there are instances wherein we would be forced to take the decisions. Here we go with a few options you can go with.

Using .htaccess in cPanel

This tutorial will show how you can change certain parameters in .htaccess file on your cPanel if you are aware of how to access your .htaccess file, move ahead directly to how to edit the file. However, for those who are not aware of how to access the file, here are the steps involved.

  • Login to your CPanel
  • Click on File Manager.
  • Click on Settings
  • Locate the box Show Hidden Files(dotfiles).
  • Click on Save.

This should now allow you to access your .htaccess file. Continue with the following steps.

  • In many cases, the .htaccessfile should be available inpublic_html
  • Open it by double-clicking on file.
  • Once you find the .htaccess file, right click on it and click on
  • Paste the following code at the top of the file

RewriteEngine On

RewriteCond %{HTTPS} on

RewriteRule (.*) HTTP://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Once you have completed all these steps, save your setting by clicking on Save Changes.

We would consider this to be one of the best and more comfortable options to redirect HTTPS requests to HTTP. In fact, it should be the most straightforward options because of the simplicity involved. You should be able to paste it in any configuration for that matter. The method works practically with all domain names, no matter whether it has www or not in the domain name.

Apart from this direct method, you also use a few plugins to redirect HTTPS connection to HTTP. You have the option of several plugins, while we will check out a couple of them.

Mavis HTTPS to HTTP Redirection

The plugin is developed by PHK Corporation and has been one of the widely used plugins to redirect HTTPS connections.

The plugin has been a savior for the E-commerce sites. This can be helpful when moving from a secured page on your site (like the checkout page, for instance) to a nonsecure page elsewhere on your site. This can be helpful in minimizing the customer disputes and the possible loss of business.

If you are interested, you may check it out at https://wordpress.org/plugins/mavis-https-to-http-redirect/. It is part of an open source software and should efficiently work for all your needs of redirecting HTTPS connections to HTTP.

Edit the functions.php file to HTTPS Redirection

Just the way you have edited the .htaccess file to redirect HTTPS requests to HTTP, you may also use the functions.php file for the purpose. This should be the best option for a WordPress blog.

Functions.php is a themes functions file which is used as a form of a template. The file also serves as a plugin for loading the homepage and admin pages. The file is also used for the purpose of defining functions, classes, actions and filters

The functions.php file is available in the themes folder. You can edit the folder and include the following code at the top of your Functions.php folder

//check if https being used regardless of certificate

functionshapeSpace_check_https() {

if ((!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] !== ‘off’) || $_SERVER[‘SERVER_PORT’] == 443) {

return true;

    }

return false;

}

  

for ($x=0; $x<1; $x++) {

//if https:// && www.

if ( shapeSpace_check_https() &&substr($_SERVER[‘HTTP_HOST’], 0, 4) === ‘www.’){

header(‘HTTP/1.1 301 Moved Permanently’);

header(‘Location: http://’ . substr($_SERVER[‘HTTP_HOST’], 4).$_SERVER[‘REQUEST_URI’]);

exit;

break;

//if only www.

    } elseif (substr($_SERVER[‘HTTP_HOST’], 0, 4) === ‘www.’) {

header(‘HTTP/1.1 301 Moved Permanently’);

header(‘Location: http://’ . substr($_SERVER[‘HTTP_HOST’], 4).$_SERVER[‘REQUEST_URI’]);

exit;

break;

    //if only https://

    } elseif( shapeSpace_check_https() ) {

header(‘HTTP/1.1 301 Moved Permanently’);

header(‘Location: http://’ . $_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]);

exit;

break;

    }

}

The Concluding Thoughts

Well, these tips should give you an insight into how to redirect HTTPS to HTTP connection on your WordPress blog. You may use any of these methods based on the ease of use you may feel with any of them. If you are editing the files for changing the connection requests, make sure you are backing up the existing data. This will ensure that you can revert if you tend to face any issues.

We would conclude that the method involving the .htaccess is the best option for redirecting HTTPS requests to HTTP.That would keep your functions.php file cleaner. Moreover, the .htaccess editing involves more straightforward tasks that can be undone if you tend to face any issues. Which of these methods do you use? Do let us know which one among those listed here worked best for you.