Options -Indexes
ServerSignature Off

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Canonical production host and HTTPS. Other development/staging hosts are left alone.
    RewriteCond %{HTTP_HOST} ^oakwoodtransport\.com$ [NC]
    RewriteRule ^ https://www.oakwoodtransport.com%{REQUEST_URI} [R=301,L,NE]

    RewriteCond %{HTTP_HOST} ^www\.oakwoodtransport\.com$ [NC]
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP:X-Forwarded-Proto} !^https$ [NC]
    RewriteRule ^ https://www.oakwoodtransport.com%{REQUEST_URI} [R=301,L,NE]

    # Remove direct front-controller URLs.
    RewriteCond %{THE_REQUEST} \s/+index\.php(?:[?\s]) [NC]
    RewriteRule ^index\.php$ / [R=301,L]

    # Legacy aliases resolve to one canonical page.
    RewriteRule ^current-opportunities/?$ /careers#current-opportunities [R=301,L,NE]
    RewriteRule ^online-forms/?$ /forms [R=301,L]
    RewriteRule ^auto-carrier-repairs/?$ /shop-service [R=301,L]
    RewriteRule ^testimonials/?$ /trust [R=301,L]
    RewriteRule ^snowbird-vehicle-shipping/?$ /snowbirds [R=301,L]
    RewriteRule ^ontario-to-florida-vehicle-shipping/?$ /snowbirds [R=301,L]
    RewriteRule ^ontario-to-arizona-vehicle-shipping/?$ /snowbirds [R=301,L]
    RewriteRule ^ontario-to-texas-vehicle-shipping/?$ /snowbirds [R=301,L]
    RewriteRule ^florida-to-ontario-vehicle-shipping/?$ /snowbirds [R=301,L]
    RewriteRule ^dealer-vehicle-transport/?$ /vehicle-shipping [R=301,L]
    RewriteRule ^classic-car-transport/?$ /vehicle-shipping [R=301,L]
    RewriteRule ^ontario-vehicle-shipping/?$ /vehicle-shipping [R=301,L]
    RewriteRule ^vehicle-shipping-ingersoll/?$ /vehicle-shipping [R=301,L]
    RewriteRule ^vehicle-shipping-london-ontario/?$ /vehicle-shipping [R=301,L]
    RewriteRule ^vehicle-shipping-gta/?$ /vehicle-shipping [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

FileETag None

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header unset ETag

    # Assets use filemtime query strings and can be cached aggressively.
    <FilesMatch "\.(css|js|png|jpg|jpeg|webp|svg|woff2|ico|pdf)$">
        Header set Cache-Control "public, max-age=31536000, immutable"
    </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType application/pdf "access plus 1 year"
</IfModule>

<FilesMatch "^\.">
    Require all denied
</FilesMatch>

ErrorDocument 404 /index.php

<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/css application/javascript text/plain application/json image/svg+xml
</IfModule>

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