# Enable rewrite engine
RewriteEngine On
RewriteBase /standardpricing/

# ------------------------------
# Remove .html extension in /standardpricing/
# ------------------------------

# Redirect .html URLs to clean URLs
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?]
RewriteRule ^ %1 [R=301,L]

# Serve .html files without typing extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ $1.html [L]

# Set /standardpricing as homepage automatically
DirectoryIndex index.html


# ----------------------------------------------------------------------
# Browser Caching for Static Assets
# ----------------------------------------------------------------------
<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png  "access plus 1 year"
  ExpiresByType image/gif  "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Fonts
  ExpiresByType font/woff "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType application/font-woff "access plus 1 year"
  ExpiresByType application/font-ttf "access plus 1 year"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 year"

  # CSS and JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
</IfModule>

# ----------------------------------------------------------------------
# Strong Cache-Control Headers
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
  <FilesMatch "\.(ico|jpe?g|png|gif|webp|svg|woff2?|ttf|eot|css|js)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
</IfModule>
