I wish to avoid .htaccess and add stuff to apache2/apache2.conf rather, because I heard .htaccess can decelerate Apache.

This Rewrite does not work inside apache2/apache2.conf. I attempted with but no luck either.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_REFERER} !^$
  RewriteRule [do things]
</IfModule>

How do i solve this?