# Lemon Jelli Bistro - SEO URL configuration
RewriteEngine On

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

# Redirect index files to homepage
RewriteRule ^index\.(html|php)$ https://lemonjellibistro.com/ [R=301,L,NC]

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

# Remove trailing slash from extensionless paths, except homepage
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.[^/]+$
RewriteRule ^(.+)/$ https://lemonjellibistro.com/$1 [R=301,L]

# Internally serve matching .html files for clean URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+)$ $1.html [L]
