Fix: Apache2 htaccess Rules not working on Bitnami LAMP

Learn how to get your application htaccess file working with Bitnami stack

Bitnami LAMP stack has its own way of handling htaccess files. Just uploading your htaccess file to document root isn’t going to cut it. I recently came a cross a request on my Bitnami bug fixing service where the client had their htaccess file ignored by Bitnami. This is how I went about solving it.

The Problem: htaccess Rules not working on Bitnami

My client was using Bitnami LAMP on a AWS LightSail instance. Their application required some custom htaccess rules to get pretty links working. This was their original request,

				
					I have a Concrete CMS website hosting on AWS LIghtsail, LAMP w/Bitnami.

We are setting up our Concrete site to not show 'index.php' in each url but it typically writes to an htaccess file.

We read the bitnami docs, and they handle their htaccess differently, they provide their own way of doing it. So, we set it up as described in the docs, and setup a test.html page to ensure it's working. If we can land on the test page it is working, if it doesn't show the test.html page it isn't.

So far, we cannot get it to show, I'm not sure why so we commented out all the lines in our htaccess.conf file for now. To test we just uncomment those lines.

I'm not sure if we did something incorrect or if it's a permission thing, not sure.

Anyways, do you have experience in the htaccess on bitnami lightsail?
				
			

Client tried to follow the official htaccess documentation from Bitnami, but they couldn’t get htaccess Rules working on Bitnami. So they reached out to me. I remembered that I came across a similar issue in the past, I wrote about it in htaccess errors on Bitnami Prestashop Stack. But it was on a Prestashop Stack. This is a LAMP stack. I needed a slightly different approach. Let’s see how I solved it this time.

The Solution: Configure Custom htaccess rules on Bitnami

As for the official documentation, htaccess files are ignored by Bitnami by default. If your application requires an htaccess file, you need to configure your bitnami stack line below.

We will start by creating a new directory to hold our configuration file.

				
					sudo mkdir /opt/bitnami/apache/conf/vhosts/htaccess
				
			

Create the configuration file with nano text editor

				
					sudo nano /opt/bitnami/apache/conf/vhosts/htaccess/htaccess.conf
				
			

Assuming your application’s document root is /home/bitnami/htdocs, paste the following snippet and save the file.

				
					    <Directory "/home/bitnami/htdocs">
      Options -Indexes +FollowSymLinks -MultiViews
      AllowOverride All
      Require all granted
    </Directory>
				
			

That tells Bitnami to look for htaccess files in /home/bitnami/htdocs directory. But you will need a restart for this change to take effect.

				
					sudo /opt/bitnami/ctlscript.sh restart
				
			

Now you can create or upload your htaccess file in the document root and it’ll be loaded by Apache2 webserver. And you should have your htaccess Rules not working on Bitnami as expected.

Tharindu

Hey!! I'm Tharindu. I'm from Sri Lanka. I'm a part time freelancer and this is my blog where I write about everything I think might be useful to readers. If you read a tutorial here and want to hire me, contact me here.

Leave a Reply

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

Back to top button