Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 473
Johnson Emmanuel Avatar asked Sep 02 '25 14:09

Johnson Emmanuel


1 Answers

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

like image 135
David Gomez Avatar answered Sep 05 '25 04:09

David Gomez