htaccess errors on Bitnami Prestashop Stack

I was working on a AWS instance where my client had trouble enabling SEO friendly URLs for PrestaShop. They used Bitnami-PrestaShop LAMP stack on a M3.Medium AWS instance. They had just migrated the shop from another host to AWS and SEO URLs began to give 404 errors after the migration.

I was initially hired to configure Route 53 hosted zone for their domain but errors kept popping up after the DNS propagation. The client or some other freelancer had moved all files over to the AWS instance, but that wasn’t enough. Since it was the SEO URLs that wasn’t working and throwing 404 errors I logged in to PrestaShop admin looked into Preference > SEO & URLs.

PrestaShop Can’t detect if mod_rewrite is enabled

There was a warning under the Friendly URL section stating PrestaShop can’t detect if mod_rewrite is enabled. Bitnami ships with mod_rewrite pre-enabled. So I realized that this error was due to a permission error. PrestaShop can’t read the htaccess file.

Looking further into the error, I noticed that the public directory is owned by the user bitnami. But Apache user was daemon. I changed the ownership of htdocs directory to user daemon by running following command.

sudo chown -R daemon:daemon /opt/bitnami/apps/prestashop/htdocs

The mod_rewrite error on PrestaShop back-end disappeared and I was finally able to enable the Friendly URLs. But SEO URLs wasn’t working yet.

Bitnami – Changes to .htaccess file isn’t making effect

Now that the .htaccess file is writable by the web server, it was automatically updated by PrestaShop with preferred rules. But it still doesn’t work. Doing some online research, I found this Bitnami Wiki page about htaccess configuration and noted that Bitnami stack no longer uses .htaccess file in the htdocs directory. Instead it uses the htaccess.conf file in the conf directory. So all I had to do was copy all the content from .htaccess to htaccess.conf file on conf directory.

Looking into htaccess.conf file carefully it contains important rules used by Bitnami. Wiping out everything is not a good idea. I just needed to change the rules of htdocs directory. So I just deleted content between the line that reads,

<Directory "/opt/bitnami/apps/prestashop/htdocs">

And the VERY FIRST line that reads,

</Directory>

And pasted everything from .htaccess file in between those two lines. I didn’t have to change anything else. I saved the changes and restarted Apache. SEO friendly URLs of PrestaShop started to work again on AWS Bitnami stack.

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.

Related Articles

2 Comments

  1. After a lot of search I implemented your change in the directory ownership to enable friendly urls in bitnami Prestashop. IT worked like a charm, thanks

Leave a Reply

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

Back to top button