Edit the httpd.conf File
If you are using Apache as your main web server, your httpd.conf or sites-available or sitename.conf file needs editing. However, your web directory needs to allow the .htaccess file to override its configuration. on debian based apache it is apache2.conf
Keep in mind, to edit this file you need to have access to the server.
Enable AllowOverride
Change your web directory override rule and enable it. Simply copy and paste the code below in the directory:
<Directory /var/www/>
AllowOverride All
</Directory>
Make sure the path in the code matches your server’s path.
Enable mod_rewrite module
To enable the mod_rewrite module, simply type the code below:
sudo a2enmod rewrite
If you have enabled this module before, you will receive a warning. In this case, you will need to restart the server by using the following code:
sudo systemctl restart apache2