Search code examples
amazon-web-services.htaccessweb-hostingbitnamiamazon-lightsail

How to enable .htaccess in AWS Lightsail LAMP module


I am new to AWS Lightsail.

I have successfully migrated my web application to a LAMP server (bitnami) and I generated SSL certificate. now I want to redirect to HTTP to HTTPS. Hence I created .htaccess and copied the below the code and restarted my server. but the page is not migrating from http to https. can you please help me to enable .htaccess?

Since I am planning to host 3 websites, I am looking for .htaccess so that I can configure locally based on the condition.

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

Thank you.


Solution

  • Bitnami Engineer here:

    By default, we disable .htaccess files due to security and performance reasons. We also move .htaccess files content to a file called htaccess.conf in the folder /opt/bitnami/apps/APPNAME/conf. You can check more about it at https://docs.bitnami.com/aws/infrastructure/lamp/administration/use-htaccess/.

    If you want to enable .htaccess usage, you would need to set it to AllowOverride All in /opt/bitnami/apache2/conf/bitnami/bitnami.conf file:

    <VirtualHost _default_:80>
      DocumentRoot "/opt/bitnami/apache2/htdocs"
      <Directory "/opt/bitnami/apache2/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All <---- HERE
        <IfVersion < 2.3 >
          Order allow,deny
          Allow from all
        </IfVersion>
        <IfVersion >= 2.3 >
          Require all granted
        </IfVersion>
      </Directory>
    

    Restart Apache after applying your changes.

    Regards