How to Set a Website Always Use HTTPS (SSL)

In this article you will read how to set .htaccess so that the website always uses HTTPS (SSL) when opened by visitors.
Share:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
How to Set a Website Always Use HTTPS (SSL)
Table Of Content:
Related Article

How do I set the website to always use HTTPS (SSL)?

Add the code below into the .htaccess file in the root directory of your website:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

1. Case Study

You have created a website and then set up SSL for your website, with the hope that visitors who open your website are always served with the HTTPS protocol .

But when you try to type in the domain in the browser, for example yourwebsite.com, the open website still uses the http://websiteanda.com protocol, the padlock icon is still open or red, which means that communication between visitors and the server is still not secure, haven't you? not encrypted properly.

Also read: How to Install Free SSL with Let's Encrypt

2. How to Add

  • You can use the cPanel/Direct Admin/ hosting panel that you have, then open the File Manager application to edit the .htaccess file , or
  • Create/Edit an .htaccess file in notepad, then transfer the file using FTP/SFTP/SCP with additional applications such as FileZilla and WinSCP .

3. Code Explanation

RewriteEngine On

Activate the rewrite module , to change the link according to our settings.

RewriteCond %{HTTPS} off

Conditioning the rewrite ( rewrite ) according to certain conditions, in this case if the website is opened with HTTP:// (or if HTTPS is off).

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

The rewrite rule, in this case the HTTP link is changed to HTTPS, and is permanent (301).

4. Additional Notes

  • Adjust the .htaccess file with the folder/directory where your website is located.
  • If your website is in a subfolder/subdirectory, then the .htaccess that must be changed is the one in that subfolder/subdirectory.

5. Cover

That 's how to set a website to always use HTTPS (SSL) when it is opened by visitors who come.

By using HTTPS, visitor data can be more secure, improve user experience and an additional step for search engine ranking optimization Google / Bing (SEO).

Hopefully useful, Happy Digitalyze your life!

Do you need services to turn your website into WordPress & Oxygen Builder?
Estimation Req

Leave a Reply

Your email address will not be published.

Related Article

iBee-Music-Mockup
Creating animated off canvas menus and hamburger buttons in Oxygen Builder
Tutorial on creating animated menu canvas and hamburger buttons in Oxygen Builder
restore from backup WordPress with WP CLI and SSH
Restore WordPress Backup with WP CLI & SSH
How to restore (restore) our WordPress data with WP CLI & SSH.
Backup Cepat WordPress dengan WP CLI & SSH
Fast WordPress Backup with WP CLI & SSH
How to quickly backup WordPress with 1 WP CLI command and 1 SSH command, create backup script and autobackup script.
COMPLETE PACKAGE OF WEBSITE DESIGN & DEVELOPMENT
Digitalizer offers website design & development services for company profiles, online shops, event organizers, educational institutions or other fields. You don't need to think about domains, web hosting / servers, DNS, email, design, development, security and other technical issues. Just prepare your website content, we do the rest.
All website design & development packages include 1 year maintenance!
Free Consultation
Back to top
cross