# .htaccess for igetbarsaus.com (Hostinger / LiteSpeed / Apache)
# Upload the CONTENTS of this folder into public_html

RewriteEngine On

# --- Force HTTPS -------------------------------------------------------
# LEAVE COMMENTED until your SSL certificate is issued and active in
# hPanel, otherwise visitors get 301'd to https before the cert exists.
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# --- Redirect www -> non-www (one canonical domain for SEO) ------------
# Matches the <link rel="canonical"> tags, which are all non-www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

# --- Extensionless URLs -> .html ---------------------------------------
# Two blog posts cross-link each other without the .html extension
# (e.g. /blog/how-to-charge-an-iget-bar-pro). Serve the real file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]

# Default document
DirectoryIndex index.html

# Custom error page
ErrorDocument 404 /404.html

# Declare charset in the HTTP Content-Type header (not just the meta tag)
AddDefaultCharset UTF-8

# Correct MIME types for types some hosts don't know
<IfModule mod_mime.c>
  AddType image/webp .webp
  AddType image/svg+xml .svg
  AddType application/manifest+json .webmanifest
</IfModule>

# Long cache for static assets (faster repeat visits)
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/svg+xml "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 font/woff2 "access plus 1 year"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

# Gzip compression — smaller transfers, faster page loads
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
  AddOutputFilterByType DEFLATE application/javascript text/javascript application/json application/xml
  AddOutputFilterByType DEFLATE image/svg+xml font/woff2 font/woff
</IfModule>

# Don't serve dotfiles
<FilesMatch "^\.">
  Require all denied
</FilesMatch>
