# =====================================================================
#  EderCloud — Under Construction / Parking Page
# =====================================================================

# --- Basics -----------------------------------------------------------
Options -Indexes -MultiViews
DirectoryIndex index.php
ServerSignature Off
AddDefaultCharset UTF-8

# --- Force HTTPS (uncomment once an SSL certificate is installed) -----
# <IfModule mod_rewrite.c>
#     RewriteEngine On
#     RewriteCond %{HTTPS} !=on
#     RewriteCond %{HTTP:X-Forwarded-Proto} !https
#     RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# </IfModule>

# --- Block hidden files, logs, source/backup files --------------------
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule (^|/)\.(?!well-known/) - [F,L]
    RewriteRule ^logs/(?!index\.php$) - [F,L]
    # Block common attack probes & bad query strings
    RewriteCond %{QUERY_STRING} (\.\./|<|>|%3C|%3E|%00|base64_encode|GLOBALS|_REQUEST|union.*select|concat\() [NC]
    RewriteRule ^ - [F,L]
    RewriteRule (^|/)(wp-admin|wp-login\.php|xmlrpc\.php|phpmyadmin|\.git|\.env|vendor/) - [F,L,NC]
    # No PATH_INFO tricks like /index.php/anything
    RewriteRule ^index\.php/. - [R=404,L]
</IfModule>
<FilesMatch "(\.(log|ai|psd|bak|old|orig|save|swp|sql|ini|env|sh|md|zip|tar|gz|lock|json|yml|yaml|dist)|~)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

# --- Block unwanted request methods -----------------------------------
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC]
    RewriteRule ^ - [R=405,L]
</IfModule>

# --- Limit request body (page accepts no uploads) ---------------------
LimitRequestBody 10240

# --- Security headers (also sent by index.php) ------------------------
# HSTS and Cross-Origin-Opener-Policy are sent by index.php only over HTTPS.
<IfModule mod_headers.c>
    Header always unset X-Powered-By
    Header unset X-Powered-By
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "DENY"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"
    Header always set X-Permitted-Cross-Domain-Policies "none"
    Header always set X-Robots-Tag "noindex, follow"
    <FilesMatch "\.(css|js|png|ico|webmanifest|xml)$">
        Header set Cross-Origin-Resource-Policy "same-site"
    </FilesMatch>
</IfModule>

# --- Correct MIME types for icons & manifest --------------------------
<IfModule mod_mime.c>
    AddType image/x-icon                  .ico
    AddType application/manifest+json     .webmanifest
    AddType application/xml               .xml
</IfModule>

# --- Compression -------------------------------------------------------
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/manifest+json application/xml image/svg+xml
</IfModule>

# --- Browser caching for static files ---------------------------------
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css                  "access plus 1 month"
    ExpiresByType application/javascript    "access plus 1 month"
    ExpiresByType image/png                 "access plus 1 year"
    ExpiresByType image/x-icon              "access plus 1 year"
    ExpiresByType application/manifest+json "access plus 1 week"
    ExpiresByType text/html                 "access plus 0 seconds"
</IfModule>

# --- Custom error pages: send visitors back to the parking page -------
ErrorDocument 403 /index.php
ErrorDocument 404 /index.php
