Changing configuration settings via htaccess files is disabled for security reasons on many hosts. So if your website shows you an Internal Server Error and you have the message “htaccess: RewriteEngine not allowed here” in your Apache error.log (ususally to be found at /var/log/apache2/error.log), you will need to first enable support for it.
This can be done by adding the line AllowOverride FileInfo to your Apache virtual host, the vhost configuration file should then look like

<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride FileInfo Order allow,deny allow from all

There is no need to add Allowoverride All instead of FileInfo to your vhosts file. While it will also work it allows way more than just rewriting URLs and could therefore be a security risk.