# Quick Shortcut Maker — Apache configuration (cPanel / shared hosting)
Options -MultiViews -Indexes
DirectoryIndex index.html
AddDefaultCharset UTF-8

<IfModule mod_mime.c>
  AddType image/webp .webp
  AddType font/woff2 .woff2
  AddType text/plain .txt
  AddType application/xml .xml
</IfModule>

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Assets requested relative to a clean URL (e.g. /blog/assets/css/style.css) -> serve real /assets/ file
  RewriteRule ^[^/]+/(assets/.+)$ $1 [L]

  # /index.html or /index -> /
  RewriteCond %{THE_REQUEST} \s/+index(\.html)?[\s?] [NC]
  RewriteRule ^ / [R=301,L]

  # /page.html -> /page/
  RewriteCond %{THE_REQUEST} \s/+([a-z0-9-]+)\.html[\s?] [NC]
  RewriteRule ^ /%1/ [R=301,L]

  # /page -> /page/ (only when page.html exists)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{DOCUMENT_ROOT}/$1.html -f
  RewriteRule ^([a-z0-9-]+)$ /$1/ [R=301,L]

  # /page/ -> page.html (internal, no redirect)
  RewriteCond %{DOCUMENT_ROOT}/$1.html -f
  RewriteRule ^([a-z0-9-]+)/$ $1.html [L]
</IfModule>


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

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType image/webp "access plus 6 months"
  ExpiresByType image/png "access plus 6 months"
  ExpiresByType image/jpeg "access plus 6 months"
  ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  <FilesMatch "\.(woff2|webp|png|jpg)$">
    Header set Cache-Control "public, max-age=15552000"
  </FilesMatch>
</IfModule>
