Skip to content

Commit dd770d5

Browse files
bassim-matarclaude
andcommitted
htaccess : redirections 301 des URLs WordPress, cache ajusté, headers sécurité
- 301 des six slugs français de l'ancien site (racine) vers /fr/ - Cache immutable réservé aux assets fingerprintés et fontes ; images remplaçables à 1 semaine, HTML à 10 min - X-Content-Type-Options, X-Frame-Options, Referrer-Policy Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6519d23 commit dd770d5

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎public/.htaccess‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ RewriteEngine On
55
RewriteCond %{HTTPS} !=on
66
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
77

8+
# legacy WordPress URLs (old site was French at the root)
9+
RedirectPermanent /fonctionnalites /fr/fonctionnalites
10+
RedirectPermanent /alimentation /fr/alimentation
11+
RedirectPermanent /geodonnees /fr/geodonnees
12+
RedirectPermanent /partenaires /fr/partenaires
13+
RedirectPermanent /presentation /fr/presentation
14+
RedirectPermanent /projet /fr/projet
15+
816
# custom 404 page
917
ErrorDocument 404 /404.html
1018

@@ -17,12 +25,21 @@ AddType image/avif .avif
1725
AddOutputFilterByType DEFLATE text/html text/css text/plain application/javascript application/json image/svg+xml
1826
</IfModule>
1927

20-
# cache: long for fingerprinted assets and images, short for HTML
28+
# cache: long for fingerprinted assets (_astro) and fonts, moderate for
29+
# images (replaceable in place under the same name), short for HTML
2130
<IfModule mod_headers.c>
22-
<FilesMatch "\.(css|js|webp|avif|png|jpe?g|svg|ico|woff2?)$">
31+
<FilesMatch "\.(css|js|woff2?)$">
2332
Header set Cache-Control "public, max-age=31536000, immutable"
2433
</FilesMatch>
34+
<FilesMatch "\.(webp|avif|png|jpe?g|svg|ico)$">
35+
Header set Cache-Control "public, max-age=604800"
36+
</FilesMatch>
2537
<FilesMatch "\.(html|xml|txt)$">
26-
Header set Cache-Control "public, max-age=3600"
38+
Header set Cache-Control "public, max-age=600"
2739
</FilesMatch>
40+
41+
# security headers
42+
Header set X-Content-Type-Options "nosniff"
43+
Header set X-Frame-Options "SAMEORIGIN"
44+
Header set Referrer-Policy "strict-origin-when-cross-origin"
2845
</IfModule>

0 commit comments

Comments
 (0)