htaccess hardening

This commit is contained in:
Jérémy Munsch 2021-09-06 17:16:38 +02:00
parent 86b8f5af9e
commit 8f2f94c3f7

View file

@ -38,20 +38,30 @@ RewriteEngine on
# Protect wp-config.php
<FilesMatch ^wp-config.php$>
deny from all
deny from all
</FilesMatch>
# Protect .htaccess et .htpasswds
<Files ~ "^.*\.([Hh][Tt][AaPp])">
order allow,deny
deny from all
</Files>
# @author JEREMY
# Protect hidden files
<FilesMatch "^\.">
Order allow,deny
Deny from all
</FilesMatch>
# Protect debug.log
<Files debug.log>
order allow,deny
deny from all
</Files>
# @author JEREMY
# Deny Everything in content folder except extensions
# css,jpeg,jpg,ico,png,gif,svg,js,eot,ttf,woff,woff2,mp4,mp3,ogg,ogv,mov,docx,doc,pdf,xml,html
RewriteRule ^content\/(.(?!.*\.css$|.*\.jpe?g$|.*\.ico$|.*\.png$|.*\.gif$|.*\.svg$|.*\.js$|.*\.eot$|.*\.ttf$|.*\.woff$|.*\.woff2$|.*\.mp4$|.*\.mp3$|.*\.ogg$|.*\.ogv$|.*\.mov$|.*\.docx$|.*\.doc$|.*\.pdf$|.*\.xml$|.*\.html$))*$ - [F]
# @author JEREMY
# Deny everything in crons folder
RewriteRule ^crons\/.*$ - [F]
# @author JEREMY
# Deny Everything in rgpd folder except needed
# css,jpeg,jpg,ico,png,gif,svg,js,eot,ttf,woff,woff2,mp4,mp3,ogg,ogv,mov,docx,doc,pdf,xml,html
# salaries/ consommateurs/
RewriteRule ^rgpd\/(.(?!.*\.css$|.*\.jpe?g$|.*\.ico$|.*\.png$|.*\.gif$|.*\.svg$|.*\.js$|.*\.eot$|.*\.ttf$|.*\.woff$|.*\.woff2$|.*\.mp4$|.*\.mp3$|.*\.ogg$|.*\.ogv$|.*\.mov$|.*\.docx$|.*\.doc$|.*\.pdf$|.*\.xml$|.*\.html$|.*index\.php$|.*onsommateurs\/$|.*alaries\/$))*$ - [F]
# Protect sql files
<FilesMatch "\.sql">
@ -73,9 +83,6 @@ RewriteEngine on
Deny from all
</files>
# protection des fichiers sys
RedirectMatch 404 /\.
#Bloquer l'indexation des fichiers PDF
<Files ~ "\.(doc|docx|pdf)$">
Header set X-Robots-Tag "noindex, nofollow"
@ -893,11 +900,18 @@ RedirectPermanent /type/jeusselin/ https://www.ldc.fr/nous-connaitre/#nos-implan
RedirectPermanent /type/s-n-v-laval/ https://www.ldc.fr/nous-connaitre/#nos-implantations
# @author Jérémy
# https://wordpress.org/support/article/hardening-wordpress/
# Block the include-only files.
<IfModule mod_rewrite.c>
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]
</IfModule>
# BEGIN WordPress
# Les directives (lignes) entre 'BEGIN WordPress' et 'END WordPress' sont