# Digital Marketing With Dave — Advantage Hosting / LiteSpeed Config

# ── MIME TYPES — must be first for LiteSpeed ─────────────────────────────────
AddType image/webp .webp
AddType image/jpeg .jpg .jpeg
AddType image/png .png
AddType image/svg+xml .svg
AddType text/html .html
AddType text/css .css
AddType application/javascript .js

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

# ── FORCE NON-WWW ─────────────────────────────────────────────────────────────
RewriteCond %{HTTP_HOST} ^www\.digitalmarketingwithdave\.com$ [NC]
RewriteRule ^(.*)$ https://digitalmarketingwithdave.com/$1 [R=301,L]

# ── CLEAN URLs — serve .html files without extension ─────────────────────────
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]

# ── GZIP COMPRESSION ─────────────────────────────────────────────────────────
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript
  AddOutputFilterByType DEFLATE image/svg+xml application/json text/plain
</IfModule>

# ── BROWSER CACHING ───────────────────────────────────────────────────────────
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "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/html "access plus 1 day"
</IfModule>

# ── SECURITY HEADERS ──────────────────────────────────────────────────────────
<IfModule mod_headers.c>
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ── CUSTOM 404 ────────────────────────────────────────────────────────────────
ErrorDocument 404 /index.html

# ── PROTECT HIDDEN FILES ──────────────────────────────────────────────────────
<FilesMatch "^\.">
  Order allow,deny
  Deny from all
</FilesMatch>
