I want to use .htaccess in AWS Lightsail.

I wanted to use .htaccess in Lightsail, so I made a note of it.

To enable htaccess, you need to modify the following file.

/opt/bitnami/apps/wordpress/conf/httpd-app.conf

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options +MultiViews +FollowSymLinks
    # AllowOverride None ←disable THIS
    AllowOverride All ←Add this
    <IfVersion < 2.3 >
        Order allow,deny

After fixing the above, restart apache.

$ sudo /opt/bitnami/ctlscript.sh restart apache

The reason I wanted to use this was because I added the Bogo plugin to build a multilingual site with WordPress, but the URL of the multilingualized site was https://xxxx.xx/, while I wanted the language name to be a subdirectory, like https://xxxx.xx/en/123 The reason for this is that the URL of the multilingualized site is now like ?lang=en, when I wanted it to be like with the language name as a subdirectory.



For this reason, after enabling the use of .htaccess in the above steps, make the .htaccess file writable with the following command, and then run

chmod 666 /apps/wordpress/htdocs/.htaccess

I made this possible by setting [Settings]-[Permalinks] in the WordPress admin panel as follows.

/%year%/%monthnum%/%day%/%post_id%

After the above settings, change the permissions back to the following.

chmod 644 /apps/wordpress/htdocs/.htaccess