I am new to AWS Light sail. 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.
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
htaccess file will open. edit it as per your requirements and press ctrl + x to exit be sure to press y to save the changes. reboot the lightsail instance. done.
if you've done configuring the SSL configuration then add the redirect option on your vhost file which you must have created for the website to view online.
Whatever modification you do to your server please make sure to create back up and always try to create new modification files. So you could use the redirect option on you app's virtual host file.
<VirtualHost *:80>
ServerName your_domain_name.com
ServerAlias www.your_domain_name.com
Redirect permanent / https://www.your_domain_name.com/
DocumentRoot /opt/bitnami/apache2/htdocs
<Directory "/opt/bitnami/apache2/htdocs">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hope this works for you.