# Prime Motor website settings for Apache/cPanel hosting (e.g. Fozzy).
# Upload this file together with the rest of the site. It starts with a dot, so it may be hidden
# in Finder: press Cmd + Shift + . to show hidden files before uploading.

# Home page
DirectoryIndex index.html index.php

RewriteEngine On

# ---- Force https --------------------------------------------------------------------------------
# Turn this ON only after the domain points here AND the SSL certificate is issued
# (cPanel > SSL/TLS Status > Run AutoSSL). To turn it on, remove the "# " from the next 2 lines.
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Also send primemotor.com.sg (without www) to https://www.primemotor.com.sg. Remove the "# " from the next 2 lines too.
# RewriteCond %{HTTP_HOST} ^primemotor\.com\.sg$ [NC]
# RewriteRule ^ https://www.primemotor.com.sg%{REQUEST_URI} [L,R=301]

# ---- Old Wix page addresses -> new pages (keeps Google links and bookmarks working) -------------
RewriteRule ^newandusedcars/?$        /new-cars.html  [R=301,L]
RewriteRule ^newandusedcars/.+$       /new-cars.html  [R=301,L]
RewriteRule ^car-financing/?$         /financing.html [R=301,L]
RewriteRule ^about-us/?$              /about.html     [R=301,L]
RewriteRule ^contact-5/?$             /contact.html   [R=301,L]
RewriteRule ^privacy-policy/?$        /privacy.html   [R=301,L]
RewriteRule ^terms-of-use/?$          /terms.html     [R=301,L]

# Friendly "page not found" page
ErrorDocument 404 /404.html

# Keep the car data files and the mail script from being listed or cached oddly
Options -Indexes

# Faster repeat visits: let browsers cache images, styles and scripts
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 30 days"
  ExpiresByType image/png  "access plus 30 days"
  ExpiresByType image/svg+xml "access plus 30 days"
  # Short cache for styles/scripts so car-list updates show up quickly
  ExpiresByType text/css "access plus 1 hour"
  ExpiresByType application/javascript "access plus 1 hour"
</IfModule>

# Compress text files
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml text/xml application/xml
</IfModule>
