# L'Oréal Box Asset Submission - Security Configuration

# Deny access to Box JWT configuration files (critical security)
<FilesMatch "^43984435_.*\.json$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Deny access to other sensitive JSON files
<FilesMatch "^(config|composer|package).*\.json$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Deny access to PHP configuration files
<FilesMatch "^config\.php$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Deny access to hidden files (like .git, .env)
<FilesMatch "^\.">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Deny access to log files
<FilesMatch "\.(log)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Deny access to README
<FilesMatch "^README\.md$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Prevent directory browsing
Options -Indexes

# Enable rewrite engine
RewriteEngine On

# Force HTTPS in production (uncomment when deploying to production)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect to index.php if accessing root
RewriteRule ^$ index.php [L]

# Security headers
<IfModule mod_headers.c>
    # Prevent clickjacking
    Header set X-Frame-Options "SAMEORIGIN"

    # XSS Protection
    Header set X-XSS-Protection "1; mode=block"

    # Prevent MIME sniffing
    Header set X-Content-Type-Options "nosniff"

    # Referrer Policy
    Header set Referrer-Policy "strict-origin-when-cross-origin"

    # Remove server signature
    Header unset Server
    Header unset X-Powered-By
</IfModule>

# PHP Security Settings (if allowed)
<IfModule mod_php.c>
    php_flag display_errors Off
    php_flag log_errors On
    php_value error_log /var/log/php_errors.log
    php_flag expose_php Off
</IfModule>

# Set default charset
AddDefaultCharset UTF-8

# Compress text files for faster loading
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>

# Cache static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
