.htaccess
Le fichier de configutation des serveurs Apache
Options +FollowSymlinks
RewriteEngine on
# Force l’https://
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=localhost
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# Réécriture d’url
RewriteRule ^accueil$ index.php [L]
RewriteRule ^nous-contacter$ contact.php [L]
RewriteRule ^article$ article.php?id=$1 [L]
RewriteRule ^(.\w*)-([0-9]+)-([A-z[:punct:]\w+]+)$ ./article.php?id=$2&slug=$3 [L]
# Autoriser des site à correspondre
SetEnvIf Origin « http(s)?://(www\.)?(site1.be|site2.be|site3.be)$ »AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header merge Vary Origin
# Désactiver l’affichage du contenu des répertoires
Options All -Indexes
# Alternative pour empêcher le listage des répertoires
IndexIgnore *
# Masquer les informations du serveur
ServerSignature Off
# Protéger les fichiers .htaccess et .htpasswds
order allow,deny
deny from all
satisfy all
# Désactiver le hotlinking de vos images
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?localhost/cqfd/ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://fakeimg.pl/400×200/?text=Pas_touche_aux_images [NC,R,L]
order allow,deny
deny from 204.12.238.58
allow from all
# Mise en cache des fichiers dans le navigateur
ExpiresActive On
ExpiresDefault « access plus 1 month »
ExpiresByType text/html « access plus 0 seconds »
ExpiresByType text/xml « access plus 0 seconds »
ExpiresByType application/xml « access plus 0 seconds »
ExpiresByType application/json « access plus 0 seconds »
ExpiresByType application/pdf « access plus 0 seconds »
ExpiresByType application/rss+xml « access plus 1 hour »
ExpiresByType application/atom+xml « access plus 1 hour »
ExpiresByType application/x-font-ttf « access plus 1 month »
ExpiresByType font/opentype « access plus 1 month »
ExpiresByType application/x-font-woff « access plus 1 month »
ExpiresByType application/x-font-woff2 « access plus 1 month »
ExpiresByType image/svg+xml « access plus 1 month »
ExpiresByType application/vnd.ms-fontobject « access plus 1 month »
ExpiresByType image/jpg « access plus 1 month »
ExpiresByType image/jpeg « access plus 1 month »
ExpiresByType image/gif « access plus 1 month »
ExpiresByType image/png « access plus 1 month »
ExpiresByType video/ogg « access plus 1 month »
ExpiresByType audio/ogg « access plus 1 month »
ExpiresByType video/mp4 « access plus 1 month »
ExpiresByType video/webm « access plus 1 month »
ExpiresByType text/css « access plus 6 month »
ExpiresByType application/javascript « access plus 6 month »
ExpiresByType application/x-shockwave-flash « access plus 1 week »
ExpiresByType image/x-icon « access plus 1 week »
# En-têtes
Header unset ETag
FileETag None
Header set Cache-Control « public »
Header set Cache-Control « public »
Header set Cache-Control « private »
Header set Cache-Control « private, must-revalidate »
# Compressions des fichiers statiques
AddOutputFilterByType DEFLATE text/xhtml text/html text/plain text/xml text/javascript application/x-javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
# Protections diverses (XSS, clickjacking et MIME-Type sniffing)
Header set X-XSS-Protection « 1; mode=block »
Header always append X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options: « nosniff »