# Ensure index.html is served automatically when visiting the folder
# URL directly (e.g. gamesji.com/arrowgame/ or gamesji.com/arrowgame)
DirectoryIndex index.html

# If someone requests the folder without a trailing slash
# (gamesji.com/arrowgame), Apache's mod_dir normally redirects to
# gamesji.com/arrowgame/ automatically and then serves index.html.
# The rewrite rules below are a fallback for configs where that
# automatic behavior is disabled.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /arrowgame/

  # If the request is for a real file or directory, don't rewrite
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Serve index.html for the bare folder request
  RewriteRule ^$ index.html [L]
</IfModule>

# Correct MIME type for the web app manifest (some servers default
# this incorrectly, which can break PWA install prompts)
<IfModule mod_mime.c>
  AddType application/manifest+json .json
</IfModule>

# Service worker must be served from the root of its scope with no
# caching, so browsers always pick up new versions promptly
<IfModule mod_headers.c>
  <FilesMatch "service-worker\.js$">
    Header set Cache-Control "no-cache, no-store, must-revalidate"
  </FilesMatch>
</IfModule>
