# ============================================================
# Threadloop (Ball Puzzle) - .htaccess
# Place this file inside the SAME /ballpuzzle/ folder as
# index.html on your Apache server.
# ============================================================

# Makes https://gamesji.com/ballpuzzle/ serve index.html directly,
# so visitors never need to type /index.html in the URL.
DirectoryIndex index.html

# ---- Correct MIME types (needed for the PWA manifest + service worker
#      to be recognized properly by browsers) ----
<IfModule mod_mime.c>
  AddType application/manifest+json .webmanifest
  AddType application/manifest+json .json
  AddType text/javascript .js
</IfModule>

# ---- Compression: smaller/faster page loads (also a minor SEO signal) ----
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json application/manifest+json image/svg+xml
</IfModule>

# ---- Caching ----
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType application/manifest+json "access plus 0 seconds"
</IfModule>
<IfModule mod_headers.c>
  # index.html and the service worker should always be revalidated so
  # visitors get your latest version quickly after you update the game.
  <FilesMatch "^(sw\.js|index\.html)$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
  # Icons rarely change, so let browsers cache them longer.
  <FilesMatch "\.(png|jpg|jpeg)$">
    Header set Cache-Control "public, max-age=2592000"
  </FilesMatch>
  Header set X-Content-Type-Options "nosniff"
</IfModule>

# ---- OPTIONAL: force HTTPS ----
# Only uncomment this if gamesji.com already has a valid SSL certificate
# working on it - otherwise this redirect will make the site unreachable.
# <IfModule mod_rewrite.c>
#   RewriteEngine On
#   RewriteCond %{HTTPS} off
#   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# </IfModule>

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