# Devorium Solutions — clean URLs, compression, caching
Options -MultiViews -Indexes
DirectoryIndex index.html

<IfModule mod_rewrite.c>
RewriteEngine On

# force https + no www (change to keep www if preferred)
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://devoriumsols.com%{REQUEST_URI} [L,R=301]

# /index.html -> /
RewriteCond %{THE_REQUEST} \s/+index\.html[\s?] [NC]
RewriteRule ^index\.html$ / [L,R=301]

# old .html links -> clean slug (keeps old URLs and shared links working)
RewriteCond %{THE_REQUEST} \s/+([^\s?]+)\.html[\s?] [NC]
RewriteRule ^ /%1 [L,R=301]

# drop trailing slash on pages
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [L,R=301]

# serve /services from services.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^([^/.]+)$ /$1.html [L]
</IfModule>

ErrorDocument 404 /index.html

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

# browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/svg+xml "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType image/jpeg "access plus 6 months"
ExpiresByType image/webp "access plus 6 months"
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "^[0-9a-f]{10}\.(css|js|svg|png|jpe?g|webp)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>
