Webhosting1st is offering reliable and cheap web hosting, prices are starting at just $10/year, for more details please check our plans.
1. I assume that You already enabled SSL certificate for Your website, for example Let's Encrypt (how to do it You can check HERE).
2. In Your /domains/domain.com/public_html directory create a file named .htaccess, if there is already such a file, edit it and add below code on top of the file.
3. Edit it and paste code:
RewriteEngine on RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]4. Save it and upload to server
That's all, Your website should redirect now all requests from http://domain.com to https://domain.com.
Adding www to Your domain.
If You wish to additionally add www to Your domain (http://example.com to https://www.example.com), above code will look like this:
RewriteEngine on RewriteCond %{HTTP_HOST} !^www. [NC] RewriteCond %{HTTP_HOST} ![0-9]$ [NC] RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]Removing www from Your domain.
If You wish to additionally remove www from Your domain (http://www.example.com to https://example.com), above code will look like this:
RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]