The same can also be accomplished in an .htaccess file, allowing for control at a directory level, provided the Directory definition has AllowOverride All. For example:
<Directory /var/www/example.com>
AllowOverride All
</Directory>

Then add the Rewrite statements above in the file /var/www/example.com/.htaccess.

Either accomplish the same, but allow control at a different level of granularity.

Want https to work for your website? Here are the steps to create an SSL certificate to use with Apache.

Generate private key
$ openssl genrsa -out ca.key 2048

Generate CSR
$ openssl req -new -key ca.key -out ca.csr

With your CSR, you can send to a third-party to sign or self-sign. Self-signed certificates will produce warnings in browsers, so you may want to consider having a Certificate Authority sign your certificate.