Apache .htaccess and mod_rewrite on Arch Linux
Enable mod_rewrite
# Uncomment LoadModule rewrite_module in /etc/httpd/conf/httpd.conf
systemctl restart httpd
Allow overrides in virtual host
<Directory /var/www/example.com/html>
AllowOverride All
Require all granted
</Directory>
Common .htaccess recipes
Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Remove www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
CMS front controller
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Block dotfiles
<FilesMatch "^\.">
Require all denied
</FilesMatch>
Gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>