# QA Platform - Apache Shared Hosting
Options -MultiViews -Indexes

RewriteEngine On

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

# ── Force www ──────────────────────────────────────────────
# RewriteCond %{HTTP_HOST} !^www\.
# RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ── Laravel Front Controller ───────────────────────────────
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# ── Security Headers ───────────────────────────────────────
<IfModule mod_headers.c>
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ── Cache Static Assets ────────────────────────────────────
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg   "access plus 1 year"
    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"
    ExpiresByType image/webp  "access plus 1 year"
    ExpiresByType text/css    "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-font-ttf "access plus 1 year"
    ExpiresByType font/woff2  "access plus 1 year"
</IfModule>

# ── Gzip Compression ───────────────────────────────────────
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    AddOutputFilterByType DEFLATE text/css application/javascript
    AddOutputFilterByType DEFLATE application/json application/xml
</IfModule>

# ── Block sensitive files ──────────────────────────────────
<FilesMatch "^\.(env|git|htaccess|htpasswd)">
    Order allow,deny
    Deny from all
</FilesMatch>
