Une porte ouverte sur ma vie numérique (et pas que) !!!
[WordPress] Quelques optimisations
On en découvre tous les jours sur WordPress !
Au menu aujourd’hui :
- Plus de sécurité.
- De la compression GZIP pour économiser de la BP ou accélérer un peu le chargement.
- De l’optimisation pour les fichiers en cache.
- Encore plus de sécurité.
Plus de sécurité.
Nous allons empêcher la modification, depuis le web, des fichiers .htaccess et wp-config.php
#secure .htaccess <Files .htaccess> Order Allow,Deny Deny from all </Files> #secure wp-config.php <Files wp-config.php> Order Deny,Allow Deny from all </Files>
De la compression GZIP
Créer un fichier gzip.php avec pour contenu :
<?php if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) && substr_count( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && !preg_match( '/(load-styles|load-scripts)\.php/', $_SERVER[ 'SCRIPT_NAME' ] ) ) ob_start( 'ob_gzhandler' ); else ob_start(); ?>
Dans le fichier .htaccess :
<FilesMatch "\.js$"> AddHandler application/x-httpd-php .js php_value default_mimetype "text/javascript" </FilesMatch> <FilesMatch "\.css$"> AddHandler application/x-httpd-php .css php_value default_mimetype "text/css" </FilesMatch> <FilesMatch "\.(htm|html|shtml)$"> AddHandler application/x-httpd-php .html php_value default_mimetype "text/html" </FilesMatch> php_value auto_prepend_file /absolute/path/to/gzip.php
Optimisation de la mise en cache des fichiers
Cela se passe toujours dans le fichier .htaccess :
ExpiresActive On ExpiresDefault A0 <FilesMatch "\.(gif|jpg|jpeg|png|swf)$"> # 2 weeks ExpiresDefault A1209600 Header append Cache-Control "public" </FilesMatch> <FilesMatch "\.(xml|txt|html)$"> # 2 hours ExpiresDefault A7200 Header append Cache-Control "proxy-revalidate" </FilesMatch> <FilesMatch "\.(js|css)$"> # 3 days ExpiresDefault A259200 Header append Cache-Control "proxy-revalidate" </FilesMatch>
Encore plus de sécurité
Et toujours dans le fichier .htaccess ![]()
# La base
ServerSignature Off
Options All -Indexes
Options +FollowSymLinks
# Filtrer certains types de requêtes.
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} ^(TRACE|DELETE|TRACK) [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
# QUERY STRING EXPLOITS
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
RewriteCond %{QUERY_STRING} tag\= [NC,OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig [NC,OR]
# RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>|'|"|;|\?|\*).* [NC,OR]
# RewriteCond %{QUERY_STRING} ^.*(%22|%27|%3C|%3E|%5C|%7B|%7C).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\.0).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(request|select|insert|union|declare|drop).* [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
# CHARACTER STRINGS
<IfModule mod_alias.c>
# BASIC CHARACTERS
RedirectMatch 403 \,
RedirectMatch 403 \:
RedirectMatch 403 \;
# RedirectMatch 403 \=
RedirectMatch 403 \@
RedirectMatch 403 \[
RedirectMatch 403 \]
RedirectMatch 403 \^
RedirectMatch 403 \`
RedirectMatch 403 \{
RedirectMatch 403 \}
RedirectMatch 403 \~
RedirectMatch 403 \"
RedirectMatch 403 \$
RedirectMatch 403 \<
RedirectMatch 403 \>
RedirectMatch 403 \|
RedirectMatch 403 \.\.
# RedirectMatch 403 \/\/
RedirectMatch 403 \%0
RedirectMatch 403 \%A
RedirectMatch 403 \%B
RedirectMatch 403 \%C
RedirectMatch 403 \%D
RedirectMatch 403 \%E
RedirectMatch 403 \%F
RedirectMatch 403 \%22
RedirectMatch 403 \%27
RedirectMatch 403 \%28
RedirectMatch 403 \%29
RedirectMatch 403 \%3C
RedirectMatch 403 \%3E
# RedirectMatch 403 \%3F
RedirectMatch 403 \%5B
RedirectMatch 403 \%5C
RedirectMatch 403 \%5D
RedirectMatch 403 \%7B
RedirectMatch 403 \%7C
RedirectMatch 403 \%7D
# COMMON PATTERNS
Redirectmatch 403 \_vpi
RedirectMatch 403 \.inc
Redirectmatch 403 xAou6
Redirectmatch 403 db\_name
Redirectmatch 403 select\(
Redirectmatch 403 convert\(
Redirectmatch 403 \/query\/
RedirectMatch 403 ImpEvData
Redirectmatch 403 \.XMLHTTP
Redirectmatch 403 proxydeny
RedirectMatch 403 function\.
Redirectmatch 403 remoteFile
Redirectmatch 403 servername
Redirectmatch 403 \&rptmode\=
Redirectmatch 403 sys\_cpanel
RedirectMatch 403 db\_connect
RedirectMatch 403 doeditconfig
RedirectMatch 403 check\_proxy
Redirectmatch 403 system\_user
Redirectmatch 403 \/\(null\)\/
Redirectmatch 403 clientrequest
Redirectmatch 403 option\_value
RedirectMatch 403 ref\.outcontrol
# SPECIFIC EXPLOITS
RedirectMatch 403 errors\.
# RedirectMatch 403 config\.
RedirectMatch 403 include\.
RedirectMatch 403 display\.
RedirectMatch 403 register\.
Redirectmatch 403 password\.
RedirectMatch 403 maincore\.
RedirectMatch 403 authorize\.
Redirectmatch 403 macromates\.
RedirectMatch 403 head\_auth\.
RedirectMatch 403 submit\_links\.
RedirectMatch 403 change\_action\.
Redirectmatch 403 com\_facileforms\/
RedirectMatch 403 admin\_db\_utilities\.
RedirectMatch 403 admin\.webring\.docs\.
Redirectmatch 403 Table\/Latest\/index\.
</IfModule>
Les règles commentées le sont car elles interfèrent avec WordPress. Si vous constatez d’autres problèmes avec ces règles il vous suffit aussi de commenter.
A savoir que cet article est une traduction/adaptation d’une partie de l’article : 20 Steps to a Flexible and Secure WordPress Installation
| Cette entrée a été posté par Jérémy Wanderscheid le 26 juillet 2010 à 21:56, et placée dans Wordpress. Vous pouvez suivre les réponses à cette entrée via RSS 2.0. Vous pouvez laisser une réponse, ou bien un trackback depuis votre site. |
Additional comments powered by BackType



about 1 month ago
[Wordpress] Quelques optimisations http://ping.fm/fw3Vi
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/865hjB
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/8651mB
This comment was originally posted on Twitter
about 1 month ago
[Geekbooster] [WordPress] Quelques optimisations http://lu.cx/8651mB
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/865FzA
This comment was originally posted on Twitter
about 1 month ago
Des optimisations wordpress, tu en veux ? en voilà : http://bit.ly/aflNGk
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/865dZA
This comment was originally posted on Twitter
about 1 month ago
Des optimisations wordpress, tu en veux ? en voilà : http://bit.ly/aflNGk #wordpress (via @davidlouis)
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/8655aC
This comment was originally posted on Twitter
about 1 month ago
[WordPress] Quelques optimisations http://lu.cx/865lbC
This comment was originally posted on Twitter
about 1 month ago
Merci bien pour toutes ces astuces !
about 1 month ago
Bonjour !
la petite question du jour : ces optimisations sont-elles valables aussi si on est en hébergement mutualisé ?
je suis chez Free, et j’hésite à bidouiller le htaccess !
Merci d’avance pour ta réponse !
about 1 week ago
Une partie des optimisations ne seront pas valable en mutualisé car a moins de connaitre ce qui est réellement en prod sur les serveurs mutualisé tu ne maitrisera pas le contexte.
about 12 hours ago
Bon, tant pis !
Merci pour ta réponse en tout cas !