Options -Indexes
ServerSignature Off

DirectoryIndex index.php

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} .+/$
RewriteRule ^(.+)/$ /$1 [R=301,L]

RewriteCond %{THE_REQUEST} \s/+index\.php[\s?] [NC]
RewriteRule ^index\.php$ / [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(?:config|cache|logs|vendor|includes)/ - [F,L]

RewriteRule ^(?:composer\.(json|lock)|package\.json|package-lock\.json)$ - [F,L]

RewriteRule ^(?:\.env|\.git|\.svn|\.DS_Store) - [F,L]

RewriteRule ^ router.php [L,QSA]

</IfModule>

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/xhtml+xml

</IfModule>

<IfModule mod_expires.c>

ExpiresActive On

# Images
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/avif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"

# Fonts
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"

# CSS
ExpiresByType text/css "access plus 1 month"

# JS
ExpiresByType application/javascript "access plus 1 month"

# PDF
ExpiresByType application/pdf "access plus 1 month"

# HTML
ExpiresByType text/html "access plus 0 seconds"

</IfModule>

<IfModule mod_headers.c>

<FilesMatch "\.(css|js)$">
Header set Cache-Control "public,max-age=2592000,immutable"
</FilesMatch>

<FilesMatch "\.(jpg|jpeg|png|gif|webp|avif|svg|woff2)$">
Header set Cache-Control "public,max-age=31536000,immutable"
</FilesMatch>

Header unset ETag

</IfModule>

FileETag None

AddType image/avif .avif
AddType image/webp .webp

Options -Indexes

<FilesMatch "^(\.htaccess|\.env|composer\.json|composer\.lock)$">
Require all denied
</FilesMatch>

<IfModule mod_headers.c>
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

ErrorDocument 403 /403
ErrorDocument 404 /404
ErrorDocument 500 /500