# SEO configuration for backfortyshinglesprings.com
# Back up your existing .htaccess before replacing it.
Options -MultiViews
RewriteEngine On

# Force HTTPS and WWW
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www\.backfortyshinglesprings\.com$ [NC]
RewriteRule ^ https://www.backfortyshinglesprings.com%{REQUEST_URI} [R=301,L,NE]

# Redirect index.html to the homepage
RewriteRule ^index\.html$ https://www.backfortyshinglesprings.com/ [R=301,L,NC]

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

# Serve clean URLs from matching .html files when present
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

# Standard error documents
ErrorDocument 400 /index.html
ErrorDocument 401 /index.html
ErrorDocument 403 /index.html
ErrorDocument 404 /index.html
ErrorDocument 500 /index.html
ErrorDocument 503 /index.html
