How To Redirect HTTP to HTTPS without WWW

How To Redirect HTTP To HTTPS Without WWW

Security is one of the three the most important factors in online activity, identification and privacy. Since from the end of 2016 all the websites are required to apply at least the basic SSL certification and encryption on their servers, domain names and internet connections the question about redirecting all traffic to HTTPS is a very important question as well.

So, how do we redirect all traffic from HTTP (unsecured) to HTTPS (secured) connection protocol?

It is easy! In order to redirect it you can add this simple and awesome code to your .htaccess file in the websites root:

(The exemplary domain name in use: yourdomain.com should be re-written with your chosen domain name)

## (comment) Redirect HTTP to HTTPS without WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC] RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301] RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]

(* How to edit your .htaccess file on server? Login to your Connect Hosting Dashboard, open File manager, navigate to the root folder of your website – If .htaccess file isn’t visible, choose Settings and ‘Show hidden files’. If .htaccess file doesn’t exist, create one.)

HTTP to HTTPS Solution for WordPress users

WordPress users have a formidable advantage to editing .htaccess file that can be achieved by using any of the available WordPress Plugins that do the same job without digging into .htaccess file creation or editing. There are a few free WordPress Plugins available that can do the job for you. Find any of the available HTTPS Redirection plugins at WordPress Plugins repository.

Recommended plugins:

Easy HTTPS Redirection – The plugin allows an automatic redirection to the “HTTPS” version/URL of the site. Make your site SSL compatible.

Really Simple SSL – No additional setup required! You only need an SSL certificate, and this plugin will do the rest.