Piccoli accorgimenti

Ecco alcuni consigli per rendere più sicuro WordPress, aggiungendo nell’htaccess alcune regole.

Disabilitare la directory listing.
Per disabilitare la directory listing, è necessario aggiungere questa regola:

Options All -Indexes

mentre se si vuole disabilitare la directory listing in una sottocartella, nell’htaccess interessato, inserire tale regola:

Options All +Indexes

Pagine di erore personalizzate

Per aggiungere le pagine personalizzate, bisogna aggiungere questa regola:


ErrorDocument 403 /percorso/pagina_di errore 403
ErrorDocument 500 /percorso/pagina_di errore 500

Proteggere l’htaccess

Per proteggere da accessi indesiderati l’htaccess, aggiungere queste regole:

<files .htaccess>
Order allow,deny
Deny from all
</files>

# WEAK PATTERN MATCHING
<Files ~ "^.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>

# STRONG HTACCESS PROTECTION
<Files ~ "^.*.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>

Disabilitare i messaggi di errore php

Inserire questa regola:

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

Abilitare e proteggere il log errori

# enable PHP error logging
php_flag  log_errors on
php_value error_log  /home/percorso/public_html/PHP_errors.log

# prevent access to PHP error log
<Files PHP_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>

Proteggere alcuni file

Inserire questa regola:

<files readme.html>
Order allow,deny
Deny from all
</files>

<files readme.txt>
Order allow,deny
Deny from all
</files>

<files install.php>
Order allow,deny
Deny from all
</files>

<files wp-config.php>
Order allow,deny
Deny from all
</files>

<files LEGGIMI.txt>
order allow,deny
deny from all
</files>

Proteggere la cartella wp-includes

##Block the include-only 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]

Proteggere la cartella wp-content

<Files ~ ".+">
Order allow,deny
Deny from all
Satisfy All
</Files>

<FilesMatch ".(css|js|png|gif|ico|jpg)$">
Order Allow,Deny
allow from all
</FilesMatch>

##ErrorDocument 403 /percorso/pagina_di errore 403

se per caso avete aggiunto anche le pagine personalizzate, decommentate l’ultima riga.

Per ora è tutto .

Fonti: