RewriteEngine On

# --- SECURITY BLOCKS ---
<FilesMatch "\.pvue$">
    Require all denied
</FilesMatch>

<FilesMatch "^App\.php$">
    Require all denied
</FilesMatch>

# Source + compiled internals (.dist, extracted deploy dirs, backend, 404 partials)
RewriteRule ^(\.dist|ajax|pages|backend|httpReqs|components|views)(/.*)?$ - [F,L]

# /section/assets/x → /assets/x (relative asset URLs on query-string pages)
RewriteCond %{REQUEST_URI} ^/([^/]+)/assets/(.*)$
RewriteRule ^ /assets/%2 [L,R=301]

# --- LEGACY REDIRECTS (before the front controller) ---
# RewriteRule ^old-page/?$ /new-page [R=301,L]

# --- FRONT CONTROLLER ---
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]

# --- OPTIONAL: FORCE HTTPS ---
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
