Force all HTTP visitors to HTTPS for security

Once you have an SSL Certificate in place for your website (included in hosting, unless you turn it off), you can force all visitors to your HTTP site to the HTTPS version.

To do this, it will take an edit of your .htaccess file that is your /public_html/ folder.

(If this seems above your skill set, please reach out to Digicom Support and we'll be glad to help you).

Add the following code to your .htaccess file only changing "yourdomain" and the ".com" to what your website domain and extension are.

# BEGIN FORCE ALL HTTP to HTTPS
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^yourdomain\.com$ [OR]
RewriteCond %{SERVER_NAME} ^www\.yourdomain\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END FORCE ALL HTTP to HTTPS

Save the .htaccess file and it should immediately take effect.

TROUBLESHOOTING:

If adding this code causes your website to give a server error when you access the website, simply remove the above code and contact support to help you add it. Sometimes 3rd Party apps that you have added to your website, will make changes to your .htaccess file that can collide with this code. Our support technicians can help find what tweeks are needed for your configuration, should this occur.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

WordPress pointing home URL to subdirectory

Pointing your home site's URL to a subdirectory In some cases, you may have a WordPress site...

How to log into cPanel

cPanel is a web hosting account management tool available on all Digicom Linux hosting plans,...

Change cPanel Password or recover lost password

Requesting a New cPanel Password If you have lost or forgotten your cPanel password, you can...

Location of Script Configuration Files

Location of Script Configuration Files These paths are relative to the root of the script, not...

Connect to MySQL Database

How to Connect to the MySQL Database In order for your MySQL database to work as intended, it...