If multiple domains are hosted, you need to add in each virtualhost, where .htaccess is to be enabled.
For example, to enable .htaccess for example.com and test.com, edit VirtualHosts:
/etc/apache2/sites-available/example.com.conf
and
/etc/apache2/sites-available/test.com.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/example.com/html>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
DocumentRoot /var/www/example.com/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and similarly, for test.com
<VirtualHost *:80>
ServerAdmin admin@test.com
ServerName test.com
ServerAlias www.test.com
<Directory /var/www/test.com/html>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
DocumentRoot /var/www/test.com/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Also if ssl is enabled, you need to edit its configuration as well:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/html
<Directory /var/www/example.com/html>
Options FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>