Forcefully redirect HTTP requests to HTTPS in Bitnami Apache

In order to redirect http requests to https, we need to make some changes in the default apache configuration file. So, before we start, make sure to backup the current config file. So that we can revert the changes if something went wrong. The location of default configuration file in bitnami is “/opt/bitnami/apache2/conf/bitnami/bitnami.conf”.

sudo cp -apf /opt/bitnami/apache2/conf/bitnami/bitnami.conf /opt/bitnami/apache2/conf/bitnami/bitnami.conf_bak

Find the VirtualHost directive and add the following lines into it. It will look like:

<VistualHost _default_:80>
   DocumentRoot “/opt/bitnami/apache2/htdocs”
   RewriteEngine On
   RewriteCond %{HTTPS} !=on
   RewriteCond %{HTTP_HOST} !^(localhost|
   RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]

Restart apache to apply the changes

sudo /opt/bitnami/ restart apache

Post navigation

Alvin Jaison

Myself Alvin Jaison. I'm a DevOps Engineer by Profession; A Mountaineer by Passion. I started this website to share DevOps related posts. Post your suggestions as a comment. You can reach me @

Leave a Reply

Your email address will not be published. Required fields are marked *