# stage 13 (NAV-05): friendly pages for a wrong address
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php

# DCP SpecHub
# Deliberately minimal: no front controller, no rewriting into subfolders.
# Every page is a real file. Nothing to misroute.

Options -Indexes -MultiViews
DirectoryIndex index.php

# Protect config + includes from direct web access
RewriteEngine On
RewriteRule ^config(/|$)   - [F,L]
# Stage 12 (W-04): include files are never pages
RewriteRule \.inc\.php$ - [F,L]
RewriteRule ^includes(/|$) - [F,L]
RewriteRule ^database(/|$) - [F,L]
# Batch P (13 Oct 2026): nothing is handed out without a sign-in and the right access
RewriteRule ^(lib|templates|desk-orig\.php|_diag\.php|README\.txt|pdfparser-vendor|newproduct-tmp)(/|$) - [F,L]
RewriteRule ^desk-files/([^/]+)$ desk-doc.php?f=$1 [L,QSA]
RewriteRule ^desk-files(/|$) - [F,L]
RewriteRule ^cpd/(.+)$ cpd-file.php?f=$1 [L,QSA]
# Stage 12 (W-09): datasheets, safety sheets, system sheets and documents only after a sign-in
RewriteRule ^(tds|msds|sds|docs)/(.+)$ doc-file.php?d=$1&f=$2 [L,QSA,B]
RewriteRule ^assets/js/(cfrp-engine-1|floor-engine-1|terrazzo-agg-data|defender-1|report-kit-1|tools-desk-1)\.js$ asset-js.php?f=$1 [L,QSA]
# Batch S: the engines' data files too
RewriteRule ^assets/data/(defender-engine-1)\.json$ asset-js.php?f=$1&t=json [L,QSA]
RewriteRule ^assets/data/ - [F,L]

<FilesMatch "^\.">
    Require all denied
</FilesMatch>

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

# stage 12 (W-17): send text compressed, and keep pictures, fonts, CSS and JS in the browser for a week
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/plain application/javascript text/javascript application/json image/svg+xml
</IfModule>
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 7 days"
    ExpiresByType image/png "access plus 7 days"
    ExpiresByType image/webp "access plus 7 days"
    ExpiresByType font/woff2 "access plus 30 days"
    ExpiresByType text/css "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
</IfModule>
