Apache rewrite module (.htaccess) can be enabled by doing the following:
1. Open the terminal.
1. Check if `mod_rewrite` is enabled. Run:
```
sudo a2enmod rewrite
```
1. If `mod_rewrite` is not enabled, it will be enabled after running the above command. If it’s already enabled, the terminal will output that `mod_rewrite` is already enabled.
1. Once the module is enabled, you need to restart the Apache server for the changes to take place. Run:
```
sudo service apache2 restart
```
1. Now, `mod_rewrite` is enabled. However, you may need to change your Apache configuration (`apache2.conf` or `httpd.conf` depending on your system) to allow `.htaccess` files. Open the configuration file. In a standard Linux install, you would type:
```
sudo nano /etc/apache2/apache2.conf
```
1. Change `AllowOverride None` to `AllowOverride All` for `Directory /var/www/` , it will look like this after you have edited:
```
```
1. Save and close the file when you are finished. In nano, you can do this by pressing `CTRL+X` and then `Y`.
1. Restart Apache again using:
```
sudo service apache2 restart
```
Now `mod_rewrite` is fully enabled, and you can use `.htaccess` files for URL rewriting.