# ---------------------------------------
# Enable URL Rewriting
# ---------------------------------------
RewriteEngine On



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

# ---------------------------------------
# Redirect index.html to root
# ---------------------------------------
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^index\.html$ https://%{HTTP_HOST}/ [R=301,L]

# ---------------------------------------
# Remove .html from URLs (hide .html in browser)
# ---------------------------------------
# Redirect .html requests to clean URL (e.g. /about.html → /about)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^([^.]+)\.html$ /$1 [R=301,L]

# Internally rewrite clean URL to .html file (e.g. /about → /about.html)
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^/]+)/?$ $1.html [L]

# ---------------------------------------
# Enable GZIP Compression
# ---------------------------------------
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json application/xml application/xhtml+xml application/rss+xml
</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"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/x-javascript "access plus 1 month"
  ExpiresByType image/x-icon "access plus 1 year"
  ExpiresDefault "access plus 7 days"
</IfModule>

# ---------------------------------------
# Font MIME Types
# ---------------------------------------
<IfModule mod_mime.c>
  AddType application/font-woff2 .woff2
  AddType application/font-woff .woff
  AddType application/vnd.ms-fontobject .eot
  AddType font/ttf .ttf
  AddType font/otf .otf
</IfModule>

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

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