Skip to content

Commit 3f86ba9

Browse files
committed
Update .htaccess
1 parent 2ab16d7 commit 3f86ba9

1 file changed

Lines changed: 32 additions & 41 deletions

File tree

src/public/content/.htaccess

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,80 @@
11
# ------------------------------------------
2-
# 🔒 Disable PHP execution for security
2+
# 🔒 Static content hardening
33
# ------------------------------------------
4-
<FilesMatch "\.(php|php[0-9]*)$">
5-
Order allow,deny
6-
Deny from all
4+
5+
Options -Indexes
6+
7+
# Disable PHP-like execution/access in static content directory.
8+
<FilesMatch "\.(?:php|phtml|phar|php[0-9]*)$">
9+
<IfModule mod_authz_core.c>
10+
Require all denied
11+
</IfModule>
12+
<IfModule !mod_authz_core.c>
13+
Order allow,deny
14+
Deny from all
15+
</IfModule>
716
</FilesMatch>
817

9-
# Alternative: Serve PHP files as plain text (uncomment if preferred)
10-
# <FilesMatch "\.(php|php[0-9]*)$">
11-
# SetHandler none
12-
# ForceType text/plain
13-
# </FilesMatch>
18+
# Prevent this static host from setting cookies.
19+
# Note: this does not stop parent-domain cookies from being sent here.
20+
<IfModule mod_headers.c>
21+
Header always unset Set-Cookie
22+
</IfModule>
1423

1524
# ------------------------------------------
16-
# 🚀 Enable browser caching for static files
25+
# 🚀 Browser caching
1726
# ------------------------------------------
1827
<IfModule mod_expires.c>
1928
ExpiresActive On
2029

21-
# Set long expiration for common static file types
2230
ExpiresByType image/jpg "access plus 1 year"
2331
ExpiresByType image/jpeg "access plus 1 year"
2432
ExpiresByType image/gif "access plus 1 year"
2533
ExpiresByType image/png "access plus 1 year"
34+
ExpiresByType image/webp "access plus 1 year"
35+
ExpiresByType image/avif "access plus 1 year"
2636
ExpiresByType image/svg+xml "access plus 1 year"
37+
2738
ExpiresByType text/css "access plus 1 month"
2839
ExpiresByType text/javascript "access plus 1 month"
2940
ExpiresByType application/javascript "access plus 1 month"
3041
ExpiresByType application/x-javascript "access plus 1 month"
42+
3143
ExpiresByType application/font-woff2 "access plus 1 year"
3244
ExpiresByType application/font-woff "access plus 1 year"
3345
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
46+
ExpiresByType font/woff2 "access plus 1 year"
47+
ExpiresByType font/woff "access plus 1 year"
3448
ExpiresByType font/ttf "access plus 1 year"
3549
ExpiresByType font/otf "access plus 1 year"
3650
</IfModule>
3751

3852
# ------------------------------------------
39-
# 💨 Enable GZIP compression
53+
# 💨 Compression
4054
# ------------------------------------------
4155
<IfModule mod_deflate.c>
4256
AddOutputFilterByType DEFLATE text/plain
4357
AddOutputFilterByType DEFLATE text/html
4458
AddOutputFilterByType DEFLATE text/xml
4559
AddOutputFilterByType DEFLATE text/css
60+
AddOutputFilterByType DEFLATE text/javascript
4661
AddOutputFilterByType DEFLATE application/javascript
47-
AddOutputFilterByType DEFLATE application/x-javascript
4862
AddOutputFilterByType DEFLATE application/json
4963
AddOutputFilterByType DEFLATE application/xml
50-
AddOutputFilterByType DEFLATE application/font-woff2
51-
AddOutputFilterByType DEFLATE application/font-woff
52-
AddOutputFilterByType DEFLATE font/ttf
53-
AddOutputFilterByType DEFLATE font/otf
64+
AddOutputFilterByType DEFLATE image/svg+xml
5465

55-
# Optional: compress everything except images
56-
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
66+
# Do not gzip already-compressed binary assets.
67+
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png|webp|avif|ico|woff2?|ttf|otf|eot)$" no-gzip dont-vary
5768
</IfModule>
5869

5970
# ------------------------------------------
60-
# 🎯 Leverage cache-control headers
71+
# 🎯 Cache-Control and security headers
6172
# ------------------------------------------
6273
<IfModule mod_headers.c>
63-
<FilesMatch "\.(ico|jpg|jpeg|png|gif|svg|css|js|woff|woff2|ttf|otf|eot)$">
74+
<FilesMatch "\.(?:ico|jpg|jpeg|png|gif|webp|avif|svg|css|js|map|woff|woff2|ttf|otf|eot)$">
6475
Header set Cache-Control "public, max-age=31536000, immutable"
6576
</FilesMatch>
66-
</IfModule>
6777

68-
# ------------------------------------------
69-
# 🛡️ Basic security headers
70-
# ------------------------------------------
71-
<IfModule mod_headers.c>
7278
Header set X-Content-Type-Options "nosniff"
73-
Header set X-Frame-Options "SAMEORIGIN"
74-
Header set X-XSS-Protection "1; mode=block"
7579
Header always set Referrer-Policy "strict-origin-when-cross-origin"
7680
</IfModule>
77-
78-
# ------------------------------------------
79-
# 🔍 Optional: Redirect to HTTPS if not already handled globally
80-
# ------------------------------------------
81-
# RewriteEngine On
82-
# RewriteCond %{HTTPS} off
83-
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
84-
85-
# ------------------------------------------
86-
# 🧼 Optional: Remove trailing slashes
87-
# ------------------------------------------
88-
# RewriteCond %{REQUEST_FILENAME} !-d
89-
# RewriteRule ^(.+)/$ /$1 [R=301,L]

0 commit comments

Comments
 (0)