# Nimbus Computers — Apache Configuration
# nimbus.in

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

# ── Force www (or no-www — remove if you prefer www) ─────────
# Uncomment the block you want:

# To redirect www → non-www (recommended since domain is nimbus.in):
# RewriteCond %{HTTP_HOST} ^www\.nimbus\.in [NC]
# RewriteRule ^(.*)$ https://nimbus.in/$1 [L,R=301]

# ── Clean URLs (optional) — redirect /about to /about.php ────
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# ── 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"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ── Prevent directory listing ─────────────────────────────────
Options -Indexes

# ── Protect sensitive files ───────────────────────────────────
<FilesMatch "^(config\.php|\.env)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

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

# ── Disable caching for TEST website ──────────────────────────
<IfModule mod_headers.c>
    Header always set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
    Header always set Pragma "no-cache"
    Header always set Expires "0"
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive Off
</IfModule>

# ── Custom error pages ────────────────────────────────────────
ErrorDocument 404 /test/404.php
ErrorDocument 500 /test/500.php
ErrorDocument 403 /test/403.php
