We are aware of a potentially service impacting issue. Learn more

Knowledgebase

How to force HTTPS using the .htaccess file

There is a big push to secure the web and islandhosting.com supports both http and https by default using Let's Encrypt free SSL.

To force all web requests to use HTTPS add following in the .htaccess file in your website’s root folder. 

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Be sure to replace www.example.com with the domain name.

To force a specific domain to use HTTPS, use the following in the .htaccess file in your website's root folder:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Make sure to replace example\.com with the domain you're trying force to https.
Additionally, you need to replace www.example.com with your domain.

If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that folder:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

Make sure you change the folder reference to the name of the folder.
Then be sure to replace www.example.com/folder with your domain name and folder.

 

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

 Automatic Backups

All about automatic backups

 DDoS Protection

DDoS stands for "Distributed Denial of Service".It is a criminal act that attempts to make a web...

 Can I get a domain and host it elsewhere?

Yes. You can.When you register a domain you will be able to login with your email and password...

 How can I view the content of my web space if I have no active domain?

When you create your account on Islandhosting.com it will put you on one of our web hosting...

 What PHP Versions Islandhosting.com supports and how to set them.

Islandhosting.com currently supports ther following PHP Versions: 4.4 5.1 5.2 5.3 5.4 5.5...