
RewriteEngine on
RewriteRule ^packers-and-movers-in-([a-zA-Z0-9-]+)\.html$ controllerpackers.php?slug=$1 [L,QSA]

RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
RewriteRule ^(.*).html/$ page404.html [NC,L]
RewriteRule ^(.*).html/(.*)$ page404.html [NC,L]
ErrorDocument 404 https://www.examplemail.com/page404.php
RewriteCond %{THE_REQUEST} \ /(.+)\.php
RewriteRule ^ /%1.html [L,R=301]
RewriteCond %{REQUEST_FILENAME} =-f
RewriteRule ^(.*)\.php$ $1.html [NC,L]
RewriteRule ^(.*)\.html$  $1.php [NC,L]

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.examplemail.com/$1 [R,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

# ===============================
# Disable Directory Browsing
# ===============================
Options -Indexes


# ===============================
# Enable GZIP Compression
# ===============================
<IfModule mod_deflate.c>

  # Compress HTML, CSS, JS, JSON, XML, Fonts
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/json
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE font/woff
  AddOutputFilterByType DEFLATE font/woff2

</IfModule>


# ===============================
# Browser Caching
# ===============================
<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType image/jpg "access 1 year"
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresByType image/webp "access 1 year"
  ExpiresByType image/svg+xml "access 1 year"

  # CSS & JS
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/javascript "access 1 month"
  ExpiresByType application/javascript "access 1 month"

  # Fonts
  ExpiresByType font/woff "access 1 year"
  ExpiresByType font/woff2 "access 1 year"

  # Default
  ExpiresDefault "access 7 days"

</IfModule>


# ===============================
# Cache-Control Headers
# ===============================
<IfModule mod_headers.c>

  <FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|css|js|woff|woff2)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>

  <FilesMatch "\.(html|htm|php)$">
    Header set Cache-Control "private, no-cache, no-store, must-revalidate"
  </FilesMatch>

</IfModule>
