Moving Rules to Config

When to Move Rules into the Main Configuration

If you can edit the main configuration, the manual says, put everything there. Keep .htaccess for shared hosting, applications that rewrite their own file (WordPress 48 , or Laravel 2,157 's public/.htaccess in Laravel), and people who may change rules but not reload. Elsewhere, moving the rules means one parse, not one per request (157 rather than 296 microseconds, The Directory Walk Cost), and typos caught by configtest instead of 500s. Rules in <Directory> keep per-directory semantics, so copy the file to a root-owned path and include it:

The application rules moved into the virtual hostXML
<Directory "/var/www/example">
  AllowOverride None
  Include /etc/apache2/site-rules/example.conf
</Directory>

After a configtest and reload, the requests of Override Classes return the same responses, the old blog URL still gets its 301, and strace shows no lookups. Never include a file the web server's user can write, since the main configuration has no AllowOverride limit. Rules moved into <VirtualHost> itself see the leading slash, so ^old-blog/ becomes ^/old-blog/ (.htaccess vs VirtualHost).