Home Server Tutorials Redirect HTTP To HTTPS Protocol On OpenLiteSpeed

Redirect HTTP To HTTPS Protocol On OpenLiteSpeed

Those of you who wish to migrate from HTTP to HTTPS on OpenLiteSpeed can read the tutorials from this post. One of the general thing to do is using HTTPs for our website.

And for OpenLiteSpeed users to migrate from HTTP to HTTPs can be by switching from port:80 to port:443. If you need to do it automatically. Because if your website can be accessed by both HTTP and HTTP protocols then Google will regard there are two different sites, that will result duplicate content.

As the result your website will perform bad, while searching the solutions to redirect my visitors from HTTP to HTTPs I found an easy method to do so.

On this post I will share the method in redirecting HTTP to HTTPS on OpenLiteSpeed, you are welcomed to follow the guides if you want to achieve the same.

  • Automatically redirect HTTP traffic to HTTPS permanently using 301 code.
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And if you use non-WWW canonical, and want the WWW to redirect to it then use the following code:

  • Automatically redirect WWW url to non-WWW with HTTPS using 301 code.
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [L,R=301]

Be sure you put the codes on the top side, because the codes are processed accordingly. From now on and forward your HTTP protocol will be redirected to HTTPS with all the traffics. This will save your website from being entitled as duplicate contents.

And hopefully this post is useful and see you again on my next tutorials and don’t forget to subscribe.


Please enter your comment!
Please enter your name here