How to redirect all traffic from http to https on LiteSpeed Servers
If you have an SSL certificate you’re likely going to want to redirect all of your traffic to the certificate or https://www variation of your domain name. By using a redirect, traffic from HTTP is sent to HTTPS and you encrypt the data that is being transferred from your website to your user’s browser. If you use our High Availability Web Hosting you can generate a free SSL certificate from your cPanel account. Resellers Account users and their customers also have access to free SSL certificates. The code used in the .htaccess file on this page is for LiteSpeed and Apache Web Servers.
Search Engines And SSLs
If search engines see your site as accessible by using http:// and https:// then this is counted as duplicate content and you could see your search engine rankings fall because of this. You can use a .htaccess file in your public_html folder to redirect all traffic to the secure version of your website. Having an SSL deployed to a website also helps with your search engine rankings.
First, if you don’t have a .htaccess file you can create one using the file manager or FTP. You can also create a WordPad document on your local computer called .htaccess and then upload it to your public_html folder. For the purpose of this guide, we’re going to redirect all traffic to https://www.
Redirect all traffic from HTTP to HTTPS
You can paste the below code into your .htaccess file and this will redirect the following protocols to https://www.domain.com
- http://domain.com
- https://domain.com
- www.domain.com
- domain.com
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
There is no need to modify the code above. The code will parse your domain name into the final action.