Step 1: Enable mod_rewrite
You can enable any Apache module using the a2enmod command. So run the command below on your Ubuntu 18.04 server:
sudo a2enmod rewrite
In case the module is already enabled on your server, you will get an alert message.
You must restart Apache once you make any change to its configuration. To do this, type the command below on a terminal window
sudo systemctl restart apache2
Your server is now ready to accept rewrite rules.