RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# =============================
# Security hardening
# =============================

# Block TRACE/TRACK
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) [NC]
RewriteRule .* - [F]

# Block access to VCS / sensitive files
RewriteRule (^|/)\.git - [F]
RewriteRule (^|/)\.svn - [F]
RewriteRule (^|/)\.hg - [F]

<FilesMatch "^(\.env|composer\.(json|lock)|package\.(json|lock))$">
  Require all denied
</FilesMatch>

# ✅ Directory listing OFF (Index of / বন্ধ)
Options -Indexes

# ✅ Default index file priority
DirectoryIndex index.php index.html

# ✅ Block access to backup/archive/source files
<FilesMatch "\.(zip|rar|7z|tar|gz|sql|bak|old|log)$">
  Require all denied
</FilesMatch>

# ✅ Prevent browsing hidden files
<FilesMatch "^\.">
  Require all denied
</FilesMatch>

# Basic security headers (if mod_headers enabled)
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
  Header set X-XSS-Protection "1; mode=block"
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
