# VideoGameLogos — Apache rules for cPanel shared hosting.
Options -Indexes -MultiViews
DirectoryIndex index.php
AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Works at the domain root or in a subfolder (example.com/logos/) without changes.
  # Only if your host maps this folder through an Alias, uncomment and set: RewriteBase /logos/

  # Never serve internal folders or dotfiles over the web.
  RewriteRule ^(app|cli|storage)(/|$) - [F,L]
  RewriteRule (^|/)\. - [F,L]

  # Real files (images, CSS, JS) and real folders (the installer) are served directly.
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Everything else goes to the front controller.
  RewriteRule ^ index.php [QSA,L]
</IfModule>

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

# Long browser caching for images and assets (file names change when content changes).
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/avif "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>

<IfModule mod_mime.c>
  AddType image/avif .avif
  AddType image/webp .webp
  AddType font/woff2 .woff2
</IfModule>

# CSS/JS are linked with ?v=<file time>, fonts never change: cache them for good.
<IfModule mod_headers.c>
  <FilesMatch "\.(css|js|woff2)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  <FilesMatch "\.(png|webp|avif|svg|ico)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

# Brotli (smaller than gzip) where the host has it; gzip otherwise.
<IfModule mod_brotli.c>
  AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml application/xml application/rss+xml application/javascript text/javascript application/json application/feed+json image/svg+xml
</IfModule>

# Compress text responses (HTML, CSS, JS, XML sitemaps, JSON, SVG).
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/rss+xml application/javascript text/javascript application/json application/feed+json image/svg+xml
</IfModule>
