Voorbeeld 1: nieuwe website op example.com
Invoer:
- Domein: example.com
- HTTPS afdwingen, adres altijd zonder www
- GZIP-compressie aan
- Caching: afbeeldingen 1 maand, CSS en JavaScript 1 week, HTML altijd opnieuw controleren
- Directorylijsten uitschakelen
Uitvoer (.htaccess):
# .htaccess gegenereerd met de .htaccess-generator van ZAP-Hosting
# Maak vóór het uploaden een reservekopie en test eerst in een testomgeving.
# HTTPS en domeinnotatie
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Algemeen en beveiliging
Options -Indexes
# Compressie
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript application/javascript application/json application/ld+json application/xml application/xhtml+xml application/rss+xml application/atom+xml image/svg+xml image/x-icon font/ttf font/otf application/vnd.ms-fontobject
</IfModule>
# Browsercaching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/webp "access plus 1 month"
ExpiresByType image/avif "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType application/xhtml+xml "access plus 0 seconds"
</IfModule>
Resultaat in woorden: Een adres als http://www.example.com/seite gaat met één 301-omleiding naar https://example.com/seite. Bezoeken via http:// zonder www worden eveneens met een 301-omleiding naar https:// gestuurd. Afbeeldingen blijven 1 maand in de browsercache (max-age=2592000), CSS en JavaScript 1 week, en HTML-pagina's worden bij elk bezoek opnieuw gecontroleerd. HTML, CSS, JavaScript en JSON worden met GZIP gecomprimeerd verzonden. Wie een map zonder index-bestand opent, ziet geen bestandenlijst meer, maar een 403-fout.
