Snelle en veilige WordPress website met plugins of .htaccess

In mijn artikelen Hoe maak ik mijn WordPress website sneller? en beveiliging van je WordPress website besprak ik de .htaccess file. Dit is een klein maar belangrijk bestandje wat je kan gebruiken om je site sneller en veiliger te maken.

Hieronder vind je de volledige code voor het .htaccess bestand dat je in de basismap (root) van je WordPress website kan uploaden. Wil je dit niet handmatig doen, dan kun je de volgende plugins gebruiken die het bestand voor je aanpassen of de beveiliging en snelheid van je website op een andere manier helpen:

[/fusion_builder_row][/fusion_builder_container]

.htaccess regels voor een snelle website

Om je website sneller te maken moet je caching van je content inschakelen en je bestanden comprimeren (kleiner maken), dit doe je met de volgende code:

# Gebruik caching van je bestanden
Header unset Pragma
FileETag None
Header unset ETag

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/ico “access 1 year”
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType image/svg+xml “access 1 year”
ExpiresByType image/x-icon “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType text/html “access 1 month”
ExpiresByType video/ogg “access 1 year”
ExpiresByType audio/ogg “access 1 year”
ExpiresByType video/mp4 “access 1 year”
ExpiresByType video/webm “access 1 year”
ExpiresByType application/pdf “access 1 month”
ExpiresByType application/javascript “access 1 month”
ExpiresByType application/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType application/x-font-woff “access 1 year”
ExpiresByType application/vnd.ms-fontobject “access 1 month”
ExpiresByType application/atom+xml “access 1 month”
ExpiresByType application/json “access plus 0 seconds”
ExpiresByType application/ld+json “access plus 0 seconds”
ExpiresByType application/vnd.geo+json “access plus 0 seconds”
ExpiresByType application/xml “access plus 0 seconds”
ExpiresByType text/xml “access plus 0 seconds”
ExpiresDefault “access 10 days”
</IfModule>

# gZIP compressie
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

# Houd de verbinding open
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>

Na het doorvoeren van deze regels kun je kijken of je website daadwerkelijk kleiner is via deze tool: http://www.whatsmyip.org/http-compression-test

.htaccess regels voor beveiliging

De volgende regels kunnen je helpen de bestanden op je website te beschermen tegen hackers:

# Blokkeer toegang tot belangrijke wordpress files

RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ – [F,L] RewriteRule !^wp-includes/ – [S=3] RewriteRule ^wp-includes/[^/]+\.php$ – [F,L] RewriteRule ^wp-includes/js/tinymce/langs/.+\.php – [F,L] RewriteRule ^wp-includes/theme-compat/ – [F,L]


order allow,deny
deny from all


order allow,deny
deny from all

# Blokkeer XML-RPC wanneer je geen remote toegang tot WP nodig hebt

Order Allow,Deny
deny from all



Require all denied


Order allow,deny
Deny from all

# Zorg dat mensen je folders niet kunnen zien
Options All -Indexes

# Stop spam

RewriteEngine On

# Reduce Comment Spam – Security > Settings > WordPress Tweaks > Comment Spam
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} /wp-comments-post\.php$
RewriteCond %{HTTP_USER_AGENT} ^$ [OR] RewriteCond %{HTTP_REFERER} !^https?://(([^/]+\.)?obesitaszorgvragenlijsten\.nl|jetpack\.wordpress\.com/jetpack-comment)(/|$) [NC] RewriteRule ^.* – [F]

En vergeet niet je .htaccess bestand af te sluiten met de WordPress regels:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Wil je een professioneel ontworpen eigen website? Neem dan contact met me op!

Voor zelfstandigen en kleine bedrijven is de Website-in-1-dag optie het meest voordelig. Reserveer op tijd een plekje, op het moment is er een wachtlijst.

Lees dan eerst het handboek voor een nieuwe website door en stuur me jouw huiswerk vragenlijst!

Wil je zelf leren ontwerpen? Boek een workshop wetenschapscommunicatie en design voor jullie afdeling!

Liesbeth Smit

Liesbeth Smit achter bureau