WordPress: bloccare le richieste maligne con il file .htaccess

Come bloccare alcuni tipi di exploit in WordPress utilizzando il file .htaccess.

WordPress di Gabriele Romanato

Se avete accesso al vostro server a livello amministrativo e analizzate i file di log, noterete una valanga di richieste sospette aventi come obiettivo file e directory riservate della vostra installazione di WordPress. Vediamo come arginare queste richieste utilizzando il file .htaccess.

Dopo aver eseguito una copia di backup del vostro file .htaccess, aggiungete il seguente codice al suo interno:


RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ ///.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\=?(http|ftp|ssl|https):/.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\?.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(asp|ini|dll).*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(htpasswd|htaccess|aahtpasswd).*\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]

Commenti