I want to use .htaccess rules in Amazon Lightsail to block an IP address from my Bitnami application.
Resolution
Locate the .htaccess file. Its default location for most applications is /opt/bitnami/apache/conf/vhosts/htaccess/your-application-htaccess.conf. For more information about .htaccess file locations, see Understand default .htaccess file configuration on the Bitnami website.
To block an IP address from your Bitnami application, complete the following steps:
-
Edit the access configuration file:
vi /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf
-
Change AllowOverride from None to All. If AllowOverride is already set to All, then proceed to step 3:
...
AllowOverride All
...
Note: Replace example-application with your application name.
-
Edit the .htaccess file:
sudo vi /opt/bitnami/apache/conf/vhosts/htaccess/example-application-htaccess.conf
Note: Replace example-application with your application name.
-
Create a rule to block the IP address:
order deny,allow
deny from example-ip-address
Note: Replace example-application with your application name and example-ip-address with the IP address that you want to block.
-
Restart Apache:
sudo /opt/bitnami/ctlscript.sh restart apache
-
Verify Apache status:
sudo /opt/bitnami/ctlscript.sh status apache