# Seth Joyner — version1
# Security & routing rules

# Updated Block --------------------------
# Disable caching and force correct headers for Decap CMS
<FilesMatch "^config\.(yml|yaml)$">
    ForceType text/yaml
    Header set Content-Type "text/yaml; charset=utf-8"
    Header unset Content-Type
    Header set Content-Type "text/yaml; charset=utf-8"
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "0"
</FilesMatch>

RewriteEngine On
RewriteRule ^config\.yml$ - [L]

# ----------------------------------------

# Protect _data folder from direct browser access
<IfModule mod_rewrite.c>
  RewriteEngine On

  # Block direct access to JSON data files
  RewriteRule ^_data/.*\.json$ - [F,L]
</IfModule>

# Deny direct directory listing
Options -Indexes

# Security headers
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set X-XSS-Protection "1; mode=block"
</IfModule>

# Cache static assets
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
</IfModule>
