# Main .htaccess for Xchange Admin
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /xchange_reg/
    
    # Force HTTPS (uncomment when ready for production)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^(.*)$ https://%{HTTP_HOST%}/$1 [R=301,L]
    
    # Prevent access to sensitive directories
    RewriteRule ^(vendor|backups|sql|archive)/.*$ - [F,L]
</IfModule>

# Security Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>

# Disable directory browsing
Options -Indexes

# Set default documents
DirectoryIndex index.html index.php

# Prevent access to sensitive files
<FilesMatch "\.(sql|log|md|env|json|lock|sh)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# 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>

# Enable browser caching
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
</IfModule>

